Search in sources :

Example 1 with SslSessionNotTrustedException

use of com.linkedin.r2.transport.http.client.common.ssl.SslSessionNotTrustedException in project rest.li by linkedin.

the class CertificateHandler method write.

@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
    _sslHandler.handshakeFuture().addListener(future -> {
        // SSLValidation, nor send anything on the channel
        if (!future.isSuccess()) {
            return;
        }
        SslSessionValidator sslSessionValidator = ctx.channel().attr(NettyChannelAttributes.SSL_SESSION_VALIDATOR).getAndSet(null);
        // Also if sslSessionValidator is the same as the previous one we cached, skipping the check.
        if (sslSessionValidator != null && !sslSessionValidator.equals(_cachedSessionValidator)) {
            _cachedSessionValidator = sslSessionValidator;
            try {
                sslSessionValidator.validatePeerSession(_sslHandler.engine().getSession());
            } catch (SslSessionNotTrustedException e) {
                ctx.fireExceptionCaught(e);
                return;
            }
        }
        ctx.write(msg, promise);
    });
}
Also used : SslSessionNotTrustedException(com.linkedin.r2.transport.http.client.common.ssl.SslSessionNotTrustedException) SslSessionValidator(com.linkedin.r2.transport.http.client.common.ssl.SslSessionValidator)

Aggregations

SslSessionNotTrustedException (com.linkedin.r2.transport.http.client.common.ssl.SslSessionNotTrustedException)1 SslSessionValidator (com.linkedin.r2.transport.http.client.common.ssl.SslSessionValidator)1