Package org.jivesoftware.smack.util
Class TLSUtils
java.lang.Object
org.jivesoftware.smack.util.TLSUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
AX509TrustManager
that doesn't validate X.509 certificates. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <B extends ConnectionConfiguration.Builder<B,
?>>
BacceptAllCertificates
(B builder) Accept all TLS certificates.static <B extends ConnectionConfiguration.Builder<B,
?>>
BDisable the hostname verification of TLS certificates.static byte[]
getChannelBindingTlsServerEndPoint
(SSLSession sslSession) Get the channel binding data for the 'tls-server-end-point' channel binding type.static FileInputStream
static org.jivesoftware.smack.util.TLSUtils.DefaultTrustStoreType
static void
Tries to determine if the default truststore type is of type jks and sets the javax.net.ssl.trustStoreType system property to 'JKS' if so.static void
setEnabledProtocolsAndCiphers
(SSLSocket sslSocket, String[] enabledProtocols, String[] enabledCiphers) static <B extends ConnectionConfiguration.Builder<B,
?>>
BsetEnabledTlsProtocolsToRecommended
(B builder) Enable the recommended TLS protocols.
-
Field Details
-
SSL
- See Also:
-
TLS
- See Also:
-
PROTO_SSL3
- See Also:
-
PROTO_TLSV1
- See Also:
-
PROTO_TLSV1_1
- See Also:
-
PROTO_TLSV1_2
- See Also:
-
PROTO_TLSV1_3
- See Also:
-
-
Constructor Details
-
TLSUtils
public TLSUtils()
-
-
Method Details
-
setEnabledTlsProtocolsToRecommended
public static <B extends ConnectionConfiguration.Builder<B,?>> B setEnabledTlsProtocolsToRecommended(B builder) Enable the recommended TLS protocols.- Type Parameters:
B
- Type of the ConnectionConfiguration builder.- Parameters:
builder
- the configuration builder to apply this setting to- Returns:
- the given builder
-
acceptAllCertificates
Accept all TLS certificates.Warning: Use with care. This method make the Connection use
TLSUtils.AcceptAllTrustManager
and essentially invalidates all security guarantees provided by TLS. Only use this method if you understand the implications.- Type Parameters:
B
- Type of the ConnectionConfiguration builder.- Parameters:
builder
- a connection configuration builder.- Returns:
- the given builder.
-
disableHostnameVerificationForTlsCertificates
public static <B extends ConnectionConfiguration.Builder<B,?>> B disableHostnameVerificationForTlsCertificates(B builder) Disable the hostname verification of TLS certificates.Warning: Use with care. This disables hostname verification of TLS certificates and essentially invalidates all security guarantees provided by TLS. Only use this method if you understand the implications.
- Type Parameters:
B
- Type of the ConnectionConfiguration builder.- Parameters:
builder
- a connection configuration builder.- Returns:
- the given builder.
-
setEnabledProtocolsAndCiphers
public static void setEnabledProtocolsAndCiphers(SSLSocket sslSocket, String[] enabledProtocols, String[] enabledCiphers) throws SmackException.SecurityNotPossibleException -
getChannelBindingTlsServerEndPoint
public static byte[] getChannelBindingTlsServerEndPoint(SSLSession sslSession) throws SSLPeerUnverifiedException, CertificateEncodingException, NoSuchAlgorithmException Get the channel binding data for the 'tls-server-end-point' channel binding type. This channel binding type is defined in RFC 5929 § 4.- Parameters:
sslSession
- the SSL/TLS session from which the data should be retrieved.- Returns:
- the channel binding data.
- Throws:
SSLPeerUnverifiedException
- if we TLS peer could not be verified.CertificateEncodingException
- if there was an encoding error with the certificate.NoSuchAlgorithmException
- if no such algorithm is available.- See Also:
-
getDefaultTruststoreStreamIfPossible
-
getDefaultTruststoreType
public static org.jivesoftware.smack.util.TLSUtils.DefaultTrustStoreType getDefaultTruststoreType() throws IOException- Throws:
IOException
-
setDefaultTrustStoreTypeToJksIfRequired
Tries to determine if the default truststore type is of type jks and sets the javax.net.ssl.trustStoreType system property to 'JKS' if so. This is meant as workaround in situations where the default truststore type is (still) 'jks' but we run on a newer JRE/JDK which uses PKCS#12 as type. See for example Gentoo bug #712290.
-