Package com.browserup.bup.mitm.util
Class SslUtil
- java.lang.Object
-
- com.browserup.bup.mitm.util.SslUtil
-
public class SslUtil extends java.lang.ObjectUtility for creating SSLContexts.
-
-
Constructor Summary
Constructors Constructor Description SslUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.lang.String>getBuiltInCipherList()Returns ciphers from the hard-coded list of "reasonable" default ciphers inDEFAULT_CIPHERS_LIST_RESOURCE.static java.util.List<java.lang.String>getDefaultCipherList()Returns a reasonable default cipher list for new client and server SSL connections.static java.util.List<java.lang.String>getEnabledJdkCipherSuites()Returns the list of default "enabled" ciphers for server TLS connections, as reported by the default Java security provider.static java.security.cert.X509CertificategetServerCertificate(javax.net.ssl.SSLSession sslSession)Returns the X509Certificate for the server this session is connected to.static io.netty.handler.ssl.SslContextgetUpstreamServerSslContext(java.util.Collection<java.lang.String> cipherSuites, TrustSource trustSource)Creates a netty SslContext for use when connecting to upstream servers.
-
-
-
Method Detail
-
getUpstreamServerSslContext
public static io.netty.handler.ssl.SslContext getUpstreamServerSslContext(java.util.Collection<java.lang.String> cipherSuites, TrustSource trustSource)Creates a netty SslContext for use when connecting to upstream servers. Retrieves the list of trusted root CAs from the trustSource. When trustSource is true, no upstream certificate verification will be performed. This will make it possible for attackers to MITM communications with the upstream server, so always supply an appropriate trustSource except in extraordinary circumstances (e.g. testing with dynamically-generated certificates).- Parameters:
cipherSuites- cipher suites to allow when connecting to the upstream servertrustSource- the trust store that will be used to validate upstream servers' certificates, or null to accept all upstream server certificates- Returns:
- an SSLContext to connect to upstream servers with
-
getServerCertificate
public static java.security.cert.X509Certificate getServerCertificate(javax.net.ssl.SSLSession sslSession)
Returns the X509Certificate for the server this session is connected to. The certificate may be null.- Parameters:
sslSession- SSL session connected to upstream server- Returns:
- the X.509 certificate from the upstream server, or null if no certificate is available
-
getEnabledJdkCipherSuites
public static java.util.List<java.lang.String> getEnabledJdkCipherSuites()
Returns the list of default "enabled" ciphers for server TLS connections, as reported by the default Java security provider. This is most likely a subset of "available" ciphers.- Returns:
- list of default server ciphers, or an empty list if the default cipher list cannot be loaded
-
getDefaultCipherList
public static java.util.List<java.lang.String> getDefaultCipherList()
Returns a reasonable default cipher list for new client and server SSL connections. Not all of the ciphers may be supported by the underlying SSL implementation (OpenSsl or JDK). The default list itself may also vary between OpenSsl and JDK implementations. SeedefaultCipherListfor implementation details.- Returns:
- default ciphers for client and server connections
-
getBuiltInCipherList
public static java.util.List<java.lang.String> getBuiltInCipherList()
Returns ciphers from the hard-coded list of "reasonable" default ciphers inDEFAULT_CIPHERS_LIST_RESOURCE.- Returns:
- ciphers from the
DEFAULT_CIPHERS_LIST_RESOURCE
-
-