Class TLSTMExtendedTrustManager
- All Implemented Interfaces:
TrustManager, X509TrustManager
- Since:
- 2.5.7
- Author:
- Frank Fock
-
Constructor Summary
ConstructorsConstructorDescriptionTLSTMExtendedTrustManager(CounterSupport tlstmCounters, TlsTmSecurityCallback<X509Certificate> securityCallback, X509TrustManager trustManager, boolean useClientMode, TransportStateReference tmStateReference) -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckClientTrusted(X509Certificate[] x509Certificates, String s) voidcheckClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) voidcheckClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) protected voidcheckServerIdentity(X509Certificate[] x509Certificates) Verifies the identity of the (D)TLS server as required by RFC 6353 §5.3.1 step 4, if the target provides an expected identity throughCertifiedIdentity.getConfiguredIdentity().voidcheckServerTrusted(X509Certificate[] x509Certificates, String s) voidcheckServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) voidcheckServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) static X509Certificate[]getAcceptedIssuers(X509TrustManager trustManager, TlsTmSecurityCallback<X509Certificate> securityCallback) Gets the acceptedX509Certificates from the givenX509TrustManagerand security callback.protected TlsTmSecurityCallback<X509Certificate> Returns the security callback to be used for the peer of the associated transport state reference.protected static booleanisMatchingDnsName(String expected, String dNSName) Matches an expected host name against adNSNamesubject alternative name, where thedNSNamemay use a wildcard for its left-most label only (RFC 6353,snmpTlstmAddrTable).
-
Constructor Details
-
TLSTMExtendedTrustManager
public TLSTMExtendedTrustManager(CounterSupport tlstmCounters, TlsTmSecurityCallback<X509Certificate> securityCallback, X509TrustManager trustManager, boolean useClientMode, TransportStateReference tmStateReference)
-
-
Method Details
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException - Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException - Throws:
CertificateException
-
getAcceptedIssuers
-
getAcceptedIssuers
public static X509Certificate[] getAcceptedIssuers(X509TrustManager trustManager, TlsTmSecurityCallback<X509Certificate> securityCallback) Gets the acceptedX509Certificates from the givenX509TrustManagerand security callback.- Parameters:
trustManager- a X509TrustManager providing the accepted issuers.securityCallback- a security callback that is ask to accept any returned issuer.- Returns:
- a probably empty or
nullarray of accepted issuers. - Since:
- 3.6.0
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException - Specified by:
checkClientTrustedin classX509ExtendedTrustManager- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException - Specified by:
checkServerTrustedin classX509ExtendedTrustManager- Throws:
CertificateException
-
getSecurityCallback
Returns the security callback to be used for the peer of the associated transport state reference. A callback configured on the target itself, seeTlsX509CertifiedTarget.getTlsTmSecurityCallback(), takes precedence over the transport mapping wide callback.- Returns:
- the security callback to use or
nullif none is configured. - Since:
- 3.13.0
-
checkServerIdentity
Verifies the identity of the (D)TLS server as required by RFC 6353 §5.3.1 step 4, if the target provides an expected identity throughCertifiedIdentity.getConfiguredIdentity(). The expected identity is matched against thedNSNameand theiPAddresssubject alternative names of the server certificate, where adNSNamemay use a wildcard for its left-most label only.Note that
CertifiedIdentity.getConfiguredIdentity()is used instead ofCertifiedIdentity.getIdentity()on purpose: the latter falls back to the security name of the target for backwards compatibility, and a security name is a principal for access control which is usually neither a host name nor an IP address. Only an identity that has been configured deliberately, for example withCertifiedTarget.setIdentity(OctetString), is verified here.If the target does not provide an expected identity, no comparison is performed. That case is left to certification path validation, the fingerprint pinning of
checkServerTrustedByFingerprint(X509Certificate[]), the security callback, and - for client mode engines - to the endpoint identification algorithm configured byDefaultSSLEngineConfiguration.setEndpointIdentificationAlgorithm(String), which makes JSSE match the certificate against the address of the target by default.- Parameters:
x509Certificates- the certificate chain of the server, where the first element is the server certificate.- Throws:
CertificateException- if an expected identity is configured, but the server certificate does not match it.- Since:
- 3.13.0
-
isMatchingDnsName
Matches an expected host name against adNSNamesubject alternative name, where thedNSNamemay use a wildcard for its left-most label only (RFC 6353,snmpTlstmAddrTable).- Parameters:
expected- the expected host name.dNSName- thedNSNameof the certificate.- Returns:
trueifexpectedmatchesdNSName.- Since:
- 3.13.0
-
checkClientTrusted
public void checkClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException - Specified by:
checkClientTrustedin classX509ExtendedTrustManager- Throws:
CertificateException
-
checkServerTrusted
public void checkServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException - Specified by:
checkServerTrustedin classX509ExtendedTrustManager- Throws:
CertificateException
-