@@ -35,9 +35,11 @@ import io.netty.handler.ssl.SupportedCipherSuiteFilter
3535import org.slf4j.LoggerFactory
3636import org.slf4j.event.Level
3737import java.net.InetSocketAddress
38+ import java.security.KeyStore
3839import java.security.PrivateKey
3940import java.security.cert.X509Certificate
4041import javax.annotation.concurrent.NotThreadSafe
42+ import javax.net.ssl.KeyManagerFactory
4143import kotlin.contracts.ExperimentalContracts
4244import kotlin.contracts.InvocationKind
4345import kotlin.contracts.contract
@@ -77,7 +79,7 @@ class HttpClientBuilder internal constructor() {
7779 .sslProvider(sslProvider)
7880 .apply {
7981 if (clientCertificate != null ) {
80- keyManager(privateKey !! , privateKeyPassword !! .joinToString( " " ), clientCertificate )
82+ keyManager(keyManagerFactory() )
8183 }
8284 }
8385 .ciphers(Http2SecurityUtil .CIPHERS , SupportedCipherSuiteFilter .INSTANCE )
@@ -117,6 +119,16 @@ class HttpClientBuilder internal constructor() {
117119 EventLoopGroupType .SECONDARY -> sharedSingleEventLoopGroup
118120 }
119121
122+ private fun keyManagerFactory () = KeyManagerFactory .getInstance(KeyManagerFactory .getDefaultAlgorithm()).apply {
123+ init (
124+ KeyStore .getInstance(" PKCS12" ).apply {
125+ load(null )
126+ setKeyEntry(" pushiko" , privateKey, privateKeyPassword, arrayOf(clientCertificate))
127+ },
128+ privateKeyPassword!!
129+ )
130+ }
131+
120132 private companion object {
121133 private val logger = Logger ()
122134 val sslProvider: SslProvider = if (OpenSsl .isAvailable()) {
0 commit comments