ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/net/openssl/OpenSSLUtil.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/tomcat/util/net/openssl/OpenSSLUtil.java
Status
scanned
Type
file
Name
OpenSSLUtil.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
4663 (4.6 KB)
MD5
3275efb69f75acd2dbf82dd52514dc8b
SHA1
854b1902c2f4212c7e6201e50423cad0eeaf2c76
SHA256
2bb55f0bc1452033e46021cc6297967376ae5629c07737d2b70757bd82c15592
SHA512

      
    
SHA1_git
df05a4c80a153eb24d30eee0fa9732283dfdc311
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
OpenSSLUtil.java | 4.6 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.net.openssl; import java.io.IOException; import java.security.KeyException; import java.security.KeyStoreException; import java.util.List; import java.util.Set; import javax.net.ssl.KeyManager; import javax.net.ssl.X509KeyManager; import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.net.SSLContext; import org.apache.tomcat.util.net.SSLHostConfigCertificate; import org.apache.tomcat.util.net.SSLUtilBase; import org.apache.tomcat.util.net.jsse.JSSEKeyManager; import org.apache.tomcat.util.res.StringManager; public class OpenSSLUtil extends SSLUtilBase { private static final Log log = LogFactory.getLog(OpenSSLUtil.class); private static final StringManager sm = StringManager.getManager(OpenSSLUtil.class); public OpenSSLUtil(SSLHostConfigCertificate certificate) { super(certificate); } @Override protected Log getLog() { return log; } @Override protected Set<String> getImplementedProtocols() { return OpenSSLEngine.IMPLEMENTED_PROTOCOLS_SET; } @Override protected Set<String> getImplementedCiphers() { return OpenSSLEngine.AVAILABLE_CIPHER_SUITES; } @Override protected boolean isTls13RenegAuthAvailable() { // OpenSSL does support authentication after the initial handshake return true; } @Override public SSLContext createSSLContextInternal(List<String> negotiableProtocols) throws Exception { return new OpenSSLContext(certificate, negotiableProtocols); } public static X509KeyManager chooseKeyManager(KeyManager[] managers, boolean throwOnMissing) throws Exception { if (managers == null) { return null; } for (KeyManager manager : managers) { if (manager instanceof JSSEKeyManager) { return (JSSEKeyManager) manager; } } for (KeyManager manager : managers) { if (manager instanceof X509KeyManager) { return (X509KeyManager) manager; } } if (throwOnMissing) { throw new IllegalStateException(sm.getString("openssl.keyManagerMissing")); } log.warn(sm.getString("openssl.keyManagerMissing.warn")); return null; } @Override public KeyManager[] getKeyManagers() throws Exception { try { return super.getKeyManagers(); } catch (IllegalArgumentException e) { // No (or invalid?) certificate chain was provided for the cert String msg = sm.getString("openssl.nonJsseChain", certificate.getCertificateChainFile()); if (log.isDebugEnabled()) { log.debug(msg, e); } else { log.info(msg); } return null; } catch (KeyStoreException | KeyException | IOException e) { // Depending on what is presented, JSSE may also throw // KeyStoreException or IOException if it doesn't understand the // provided file. if (certificate.getCertificateFile() != null) { String msg = sm.getString("openssl.nonJsseCertificate", certificate.getCertificateFile(), certificate.getCertificateKeyFile()); if (log.isDebugEnabled()) { log.debug(msg, e); } else { log.info(msg); } // Assume JSSE processing of the certificate failed, try again with OpenSSL // without a key manager return null; } throw e; } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
26.39
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9