You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to have the possibility to retrieve the server certificates, something like:
val Url = new URL(url)
val con = Url.openConnection
val scon = con.asInstanceOf[HttpsURLConnection]
scon.connect()
val certs = scon.getServerCertificates
After initial talk with Adam, certs might be added to ResponseMetadata and the syntax may look as: (ignore: ResponseAs[Unit]).mapWithMetadata(m => extract cert)
The text was updated successfully, but these errors were encountered:
This issue was created when I asked @wojciechUrbanski how I can do certificate pinning via sttp because I didn't find the way at that time.
But, I found the way after that.
The X509TrustManager class enables us to access server certificates as it's written here
// custom X509TrustManagervalTrustAllCerts:X509TrustManager=newX509TrustManager() {
defgetAcceptedIssuers:Array[X509Certificate] =Array[X509Certificate]()
overridedefcheckServerTrusted(x509Certificates: Array[X509Certificate], s: String):Unit= {
// here you can access server certificates
}
overridedefcheckClientTrusted(x509Certificates: Array[X509Certificate], s: String):Unit= ()
}
// configure trusted server certificates
ks.load(newFileInputStream("/path/to/server_trust"), "password".toCharArray)
// check the certificate with the default algorithm (normally PKIX)// reference: [https://docs.oracle.com/en/java/javase/11/docs/api/java.base/javax/net/ssl/TrustManagerFactory.html]valtmf:TrustManagerFactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm)
tmf.init(ks)
Feature:
I would like to have the possibility to retrieve the server certificates, something like:
After initial talk with Adam, certs might be added to
ResponseMetadata
and the syntax may look as:(ignore: ResponseAs[Unit]).mapWithMetadata(m => extract cert)
The text was updated successfully, but these errors were encountered: