MCPcopy Create free account
hub / github.com/apache/tomcat / OpenSSLContext

Class OpenSSLContext

java/org/apache/tomcat/util/net/openssl/OpenSSLContext.java:66–714  ·  view source on GitHub ↗

OpenSSL implementation of the SSL context.

Source from the content-addressed store, hash-verified

64 * OpenSSL implementation of the SSL context.
65 */
66public class OpenSSLContext implements org.apache.tomcat.util.net.SSLContext {
67
68 private static final Log log = LogFactory.getLog(OpenSSLContext.class);
69 private static final StringManager sm = StringManager.getManager(OpenSSLContext.class);
70
71 private static final String defaultProtocol = "TLS";
72
73 private static final String BEGIN_KEY = "-----BEGIN PRIVATE KEY-----\n";
74 private static final String END_KEY = "\n-----END PRIVATE KEY-----";
75
76 /**
77 * X509 certificate factory instance.
78 */
79 static final CertificateFactory X509_CERT_FACTORY;
80 static {
81 try {
82 X509_CERT_FACTORY = CertificateFactory.getInstance("X.509");
83 } catch (CertificateException e) {
84 throw new IllegalStateException(sm.getString("openssl.X509FactoryError"), e);
85 }
86 }
87
88 private static final Cleaner cleaner = Cleaner.create();
89
90 private final SSLHostConfig sslHostConfig;
91 private final SSLHostConfigCertificate certificate;
92 private final List<String> negotiableProtocols;
93
94 private OpenSSLSessionContext sessionContext;
95 private X509TrustManager x509TrustManager;
96 private String enabledProtocol;
97 private boolean initialized = false;
98
99 private final OpenSSLState state;
100 private final Cleanable cleanable;
101
102 /**
103 * Constructs an OpenSSLContext for the given certificate and protocols.
104 *
105 * @param certificate The SSL host config certificate
106 * @param negotiableProtocols The list of negotiable protocols
107 * @throws SSLException if initialization fails
108 */
109 public OpenSSLContext(SSLHostConfigCertificate certificate, List<String> negotiableProtocols) throws SSLException {
110 this.sslHostConfig = certificate.getSSLHostConfig();
111 this.certificate = certificate;
112 long aprPool = Pool.create(0);
113 long cctx = 0;
114 long ctx = 0;
115 boolean success = false;
116 try {
117 // Create OpenSSLConfCmd context if used
118 if (sslHostConfig.getOpenSslConf() == null && sslHostConfig.getTrustManagerClassName() == null &&
119 sslHostConfig.getTruststore() == null) {
120 /*
121 * If an instance of OpenSSLConf is required, it must be created here so the reference can be placed in
122 * the (immutable) OpenSSLState record.
123 *

Callers

nothing calls this directly

Calls 5

getLogMethod · 0.95
getManagerMethod · 0.95
getInstanceMethod · 0.65
getStringMethod · 0.65
createMethod · 0.65

Tested by

no test coverage detected