Java Code Examples for javax.net.ssl.SSLEngine#getPeerHost()

The following examples show how to use javax.net.ssl.SSLEngine#getPeerHost() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtensibleTrustManagerImpl.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
private X509ExtendedTrustManager getLinkedTrustMananger(X509Certificate[] chain, SSLEngine sslEngine) {
    if (sslEngine != null) {
        X509ExtendedTrustManager trustManager = null;
        String peer = null;
        if (sslEngine.getPeerHost() != null) {
            peer = sslEngine.getPeerHost() + ":" + sslEngine.getPeerPort();
            trustManager = linkedTrustManager.getOrDefault(peer, EMPTY_QUEUE).peek();
        }

        if (trustManager != null) {
            logger.trace("Found trustManager by sslEngine peer/host: {}", peer);
            return trustManager;
        } else {
            logger.trace("Did NOT find trustManager by sslEngine peer/host: {}", peer);
        }
    }
    return getLinkedTrustMananger(chain);
}
 
Example 2
Source File: ExtensibleTrustManagerImpl.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private X509ExtendedTrustManager getLinkedTrustMananger(X509Certificate[] chain, SSLEngine sslEngine) {
    if (sslEngine != null) {
        X509ExtendedTrustManager trustManager = null;
        String peer = null;
        if (sslEngine.getPeerHost() != null) {
            peer = sslEngine.getPeerHost() + ":" + sslEngine.getPeerPort();
            trustManager = linkedTrustManager.getOrDefault(peer, EMPTY_QUEUE).peek();
        }

        if (trustManager != null) {
            logger.trace("Found trustManager by sslEngine peer/host: {}", peer);
            return trustManager;
        } else {
            logger.trace("Did NOT find trustManager by sslEngine peer/host: {}", peer);
        }
    }
    return getLinkedTrustMananger(chain);
}
 
Example 3
Source File: ZalyTrustManagerFactory.java    From wind-im with Apache License 2.0 5 votes vote down vote up
@Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1, SSLEngine arg2)
		throws CertificateException {
	logger.debug("check ssl server trusted certificate : {} {} sslEngine={} ", arg0[0].getSubjectDN(), arg1,
			arg2.toString());

	String peerHost = arg2.getPeerHost();
	Principal pri = arg0[0].getSubjectDN();
	String serverHost = pri.getName().substring(3);
	if (StringUtils.isEmpty(serverHost) || !serverHost.equals(peerHost)) {
		throw new CertificateException("untrust server host : " + serverHost);
	}

}
 
Example 4
Source File: ZalyTrustManagerFactory.java    From openzaly with Apache License 2.0 5 votes vote down vote up
@Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1, SSLEngine arg2)
		throws CertificateException {
	logger.debug("check ssl server trusted certificate : {} {} sslEngine={} ", arg0[0].getSubjectDN(), arg1,
			arg2.toString());

	String peerHost = arg2.getPeerHost();
	Principal pri = arg0[0].getSubjectDN();
	String serverHost = pri.getName().substring(3);
	if (StringUtils.isEmpty(serverHost) || !serverHost.equals(peerHost)) {
		throw new CertificateException("untrust server host : " + serverHost);
	}

}
 
Example 5
Source File: ZalyTrustManagerFactory.java    From openzaly with Apache License 2.0 5 votes vote down vote up
@Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1, SSLEngine arg2)
		throws CertificateException {
	logger.debug("check ssl server trusted certificate : {} {} sslEngine={} ", arg0[0].getSubjectDN(), arg1,
			arg2.toString());

	String peerHost = arg2.getPeerHost();
	Principal pri = arg0[0].getSubjectDN();
	String serverHost = pri.getName().substring(3);
	if (StringUtils.isEmpty(serverHost) || !serverHost.equals(peerHost)) {
		throw new CertificateException("untrust server host : " + serverHost);
	}

}