Code Monkey home page Code Monkey logo

Comments (2)

fabiomsr avatar fabiomsr commented on September 24, 2024 1

I think it should be android.util.Base64?

Yes.

You should remove these lines.

 byte[] publicKeyShaBase64 = Base64.getEncoder().encode(publicKeySha256);
return "sha256/" + new String(publicKeyShaBase64);

And add:

return "sha256/" + Base64.encodeToString(publicKeySha256, Base64.DEFAULT);

from okhttp-peer-certificate-extractor.

roblav96 avatar roblav96 commented on September 24, 2024

@fabiomsr I found out that using okhttp3 you can call the method okhttp3.CertificatePinner.pin(x509Certificate) for example:

let inputStream: java.io.FileInputStream
try {
	let file = new java.io.File(options.certificateURI)
	inputStream = new java.io.FileInputStream(file)
	let x509Certificate = java.security.cert.CertificateFactory.getInstance('X509').generateCertificate(inputStream)
	peer.x509Certificate = x509Certificate
	certificate = okhttp3.CertificatePinner.pin(x509Certificate)
	inputStream.close()
} catch (error) {
	try {
		if (inputStream) {
			inputStream.close()
		}
	} catch (e) { }
	console.error('nativescript-https > enableSSLPinning error', error)
	return
}
// certificate = sha256/u4QJrwx7aSejc080BBQKGyTaoJovFBg4SbQ9nhoohb8=

Used in this library I wrote for Nativescript https://github.com/gethuman/nativescript-https/blob/master/https.android.ts#L41

from okhttp-peer-certificate-extractor.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.