mirror of
https://github.com/square/okhttp.git
synced 2025-08-08 23:42:08 +03:00
Fail on unencodable keys (#6468)
This commit is contained in:
@@ -30,6 +30,7 @@ import okhttp3.internal.platform.Platform
|
|||||||
import okhttp3.internal.toImmutableList
|
import okhttp3.internal.toImmutableList
|
||||||
import okhttp3.tls.internal.TlsUtil.newKeyManager
|
import okhttp3.tls.internal.TlsUtil.newKeyManager
|
||||||
import okhttp3.tls.internal.TlsUtil.newTrustManager
|
import okhttp3.tls.internal.TlsUtil.newTrustManager
|
||||||
|
import java.security.KeyStoreException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Certificates to identify which peers to trust and also to earn the trust of those peers in kind.
|
* Certificates to identify which peers to trust and also to earn the trust of those peers in kind.
|
||||||
@@ -172,6 +173,12 @@ class HandshakeCertificates private constructor(
|
|||||||
|
|
||||||
fun build(): HandshakeCertificates {
|
fun build(): HandshakeCertificates {
|
||||||
val immutableInsecureHosts = insecureHosts.toImmutableList()
|
val immutableInsecureHosts = insecureHosts.toImmutableList()
|
||||||
|
|
||||||
|
val heldCertificate = heldCertificate
|
||||||
|
if (heldCertificate != null && heldCertificate.keyPair.private.format == null) {
|
||||||
|
throw KeyStoreException("unable to support unencodable private key")
|
||||||
|
}
|
||||||
|
|
||||||
val keyManager = newKeyManager(null, heldCertificate, *(intermediates ?: emptyArray()))
|
val keyManager = newKeyManager(null, heldCertificate, *(intermediates ?: emptyArray()))
|
||||||
val trustManager = newTrustManager(null, trustedCertificates, immutableInsecureHosts)
|
val trustManager = newTrustManager(null, trustedCertificates, immutableInsecureHosts)
|
||||||
return HandshakeCertificates(keyManager, trustManager)
|
return HandshakeCertificates(keyManager, trustManager)
|
||||||
|
Reference in New Issue
Block a user