public class DaneVerifier extends Object
Constructor and Description |
---|
DaneVerifier() |
DaneVerifier(AbstractDnsClient client) |
Modifier and Type | Method and Description |
---|---|
HttpsURLConnection |
verifiedConnect(HttpsURLConnection conn)
Invokes
URLConnection.connect() in a DANE verified fashion. |
HttpsURLConnection |
verifiedConnect(HttpsURLConnection conn,
X509TrustManager trustManager)
Invokes
URLConnection.connect() in a DANE verified fashion. |
boolean |
verify(SSLSession session)
Verifies the certificate chain in an active
SSLSession . |
boolean |
verify(SSLSocket socket)
Verifies the certificate chain in an active
SSLSocket . |
boolean |
verifyCertificateChain(X509Certificate[] chain,
String hostName,
int port)
Verifies a certificate chain to be valid when used with the given connection details using DANE.
|
public DaneVerifier()
public DaneVerifier(AbstractDnsClient client)
public boolean verify(SSLSocket socket) throws CertificateException
SSLSocket
. The socket must be connected.socket
- A connected SSLSocket
whose certificate chain shall be verified using DANE.false
, additional PKIX validation is required.CertificateException
- if the certificate chain provided differs from the one enforced using DANE.public boolean verify(SSLSession session) throws CertificateException
SSLSession
.session
- An active SSLSession
whose certificate chain shall be verified using DANE.false
, additional PKIX validation is required.CertificateException
- if the certificate chain provided differs from the one enforced using DANE.public boolean verifyCertificateChain(X509Certificate[] chain, String hostName, int port) throws CertificateException
chain
- A certificate chain that should be verified using DANE.hostName
- The DNS name of the host this certificate chain belongs to.port
- The port number that was used to reach the server providing the certificate chain in question.false
, additional PKIX validation is required.CertificateException
- if the certificate chain provided differs from the one enforced using DANE.public HttpsURLConnection verifiedConnect(HttpsURLConnection conn) throws IOException, CertificateException
URLConnection.connect()
in a DANE verified fashion.
This method must be called before URLConnection.connect()
is invoked.
If a SSLSocketFactory was set on this HttpsURLConnection, it will be ignored. You can use
verifiedConnect(HttpsURLConnection, X509TrustManager)
to inject a custom TrustManager
.conn
- connection to be connected.HttpsURLConnection
after being connected.IOException
- when the connection could not be established.CertificateException
- if there was an exception while verifying the certificate.public HttpsURLConnection verifiedConnect(HttpsURLConnection conn, X509TrustManager trustManager) throws IOException, CertificateException
URLConnection.connect()
in a DANE verified fashion.
This method must be called before URLConnection.connect()
is invoked.
If a SSLSocketFactory was set on this HttpsURLConnection, it will be ignored.conn
- connection to be connected.trustManager
- A non-default TrustManager
to be used.HttpsURLConnection
after being connected.IOException
- when the connection could not be established.CertificateException
- if there was an exception while verifying the certificate.