1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty5.handler.ssl;
17
18 import io.netty.internal.tcnative.SSL;
19
20 import javax.net.ssl.KeyManagerFactory;
21 import javax.net.ssl.SSLException;
22 import javax.net.ssl.TrustManagerFactory;
23 import java.security.PrivateKey;
24 import java.security.cert.X509Certificate;
25 import java.util.Map;
26
27 import static io.netty5.handler.ssl.ReferenceCountedOpenSslClientContext.newSessionContext;
28
29
30
31
32
33
34 final class OpenSslClientContext extends OpenSslContext {
35 private final OpenSslSessionContext sessionContext;
36
37 OpenSslClientContext(X509Certificate[] trustCertCollection, TrustManagerFactory trustManagerFactory,
38 X509Certificate[] keyCertChain, PrivateKey key, String keyPassword,
39 KeyManagerFactory keyManagerFactory, Iterable<String> ciphers,
40 CipherSuiteFilter cipherFilter, ApplicationProtocolConfig apn, String[] protocols,
41 long sessionCacheSize, long sessionTimeout, boolean enableOcsp, String keyStore,
42 Map.Entry<SslContextOption<?>, Object>... options)
43 throws SSLException {
44 super(ciphers, cipherFilter, apn, SSL.SSL_MODE_CLIENT, keyCertChain,
45 ClientAuth.NONE, protocols, false, enableOcsp, options);
46 boolean success = false;
47 try {
48 OpenSslKeyMaterialProvider.validateKeyMaterialSupported(keyCertChain, key, keyPassword);
49 sessionContext = newSessionContext(this, ctx, engineMap, trustCertCollection, trustManagerFactory,
50 keyCertChain, key, keyPassword, keyManagerFactory, keyStore,
51 sessionCacheSize, sessionTimeout);
52 success = true;
53 } finally {
54 if (!success) {
55 release();
56 }
57 }
58 }
59
60 @Override
61 public OpenSslSessionContext sessionContext() {
62 return sessionContext;
63 }
64 }