Example usage for io.vertx.core.net NetSocket peerCertificateChain

List of usage examples for io.vertx.core.net NetSocket peerCertificateChain

Introduction

In this page you can find the example usage for io.vertx.core.net NetSocket peerCertificateChain.

Prototype

@GenIgnore
X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException;

Source Link

Document

Note: Java SE 5+ recommends to use javax.net.ssl.SSLSession#getPeerCertificates() instead of of javax.net.ssl.SSLSession#getPeerCertificateChain() which this method is based on.

Usage

From source file:org.eclipse.hono.server.HonoSaslAuthenticator.java

License:Open Source License

@Override
public void init(final NetSocket socket, final ProtonConnection protonConnection, final Transport transport) {
    LOG.debug("initializing SASL authenticator");
    this.protonConnection = protonConnection;
    this.sasl = transport.sasl();
    // TODO determine supported mechanisms dynamically based on registered AuthenticationService implementations
    sasl.server();//from ww  w.j a v a2 s . c  o m
    sasl.allowSkip(false);
    sasl.setMechanisms(MECHANISM_EXTERNAL, MECHANISM_PLAIN);
    if (socket.isSsl()) {
        LOG.debug("client connected using TLS, extracting client certificate chain");
        try {
            peerCertificateChain = socket.peerCertificateChain();
            LOG.debug("found valid client certificate DN [{}]", peerCertificateChain[0].getSubjectDN());
        } catch (SSLPeerUnverifiedException e) {
            LOG.debug(
                    "could not extract client certificate chain, maybe TLS based client auth is not required");
        }
    }
}