Example usage for io.netty.handler.ssl OpenSsl ensureAvailability

List of usage examples for io.netty.handler.ssl OpenSsl ensureAvailability

Introduction

In this page you can find the example usage for io.netty.handler.ssl OpenSsl ensureAvailability.

Prototype

public static void ensureAvailability() 

Source Link

Document

Ensure that <a href="https://netty.io/wiki/forked-tomcat-native.html"> netty-tcnative </a> and its OpenSSL support are available.

Usage

From source file:blazingcache.network.netty.NetworkUtils.java

License:Apache License

public static boolean isOpenSslAvailable() {
    if (openSslAvailable != null) {
        return openSslAvailable;
    }/*from  w w w. j a v  a  2s  .c  o  m*/
    if (ENABLE_OPENSSL && OpenSsl.isAvailable()) {
        OpenSsl.ensureAvailability();
        openSslAvailable = true;
    } else {
        Throwable cause = OpenSsl.unavailabilityCause();
        LOG.log(Level.INFO, "Native OpenSSL support is not available on this platform: " + cause);
        openSslAvailable = false;
    }
    return openSslAvailable;
}

From source file:ch.uninbf.mcs.tomcatopenssl.net.ssl.open.OpenSSLContext.java

public OpenSSLContext() throws SSLException {
    OpenSsl.ensureAvailability();
    aprPool = Pool.create(0);/*w  w  w .j a va2s  . c  om*/

    try {
        synchronized (OpenSSLContext.class) {
            try {
                ctx = SSLContext.make(aprPool, SSL.SSL_PROTOCOL_ALL, SSL.SSL_MODE_SERVER);
            } catch (Exception e) {
                throw new SSLException("failed to create an SSL_CTX", e);
            }

            SSLContext.setOptions(ctx, SSL.SSL_OP_ALL);
            SSLContext.setOptions(ctx, SSL.SSL_OP_NO_SSLv2);
            SSLContext.setOptions(ctx, SSL.SSL_OP_NO_SSLv3);
            SSLContext.setOptions(ctx, SSL.SSL_OP_CIPHER_SERVER_PREFERENCE);
            SSLContext.setOptions(ctx, SSL.SSL_OP_SINGLE_ECDH_USE);
            SSLContext.setOptions(ctx, SSL.SSL_OP_SINGLE_DH_USE);
            SSLContext.setOptions(ctx, SSL.SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION);
        }
        //            success = true;
    } finally {
        //            if (!success) {
        //                destroyPools();
        //            }
    }
}

From source file:ch.uninbf.mcs.tomcatopenssl.net.ssl.open.OpenSslEngine.java

License:Apache License

/**
 * Creates a new instance/*from  w ww.j av  a 2s .c  om*/
 *
 * @param sslCtx an OpenSSL {@code SSL_CTX} object
 * @param alloc the {@link ByteBufAllocator} that will be used by this
 * engine
 * @param clientMode {@code true} if this is used for clients, {@code false}
 * otherwise
 * @param sessionContext the {@link OpenSslSessionContext} this
 * {@link SSLEngine} belongs to.
 */
OpenSslEngine(long sslCtx, String fallbackApplicationProtocol, boolean clientMode,
        OpenSslSessionContext sessionContext) {
    OpenSsl.ensureAvailability();
    if (sslCtx == 0) {
        throw new NullPointerException("sslContext");
    }

    ssl = SSL.newSSL(sslCtx, !clientMode);
    networkBIO = SSL.makeNetworkBIO(ssl);
    this.fallbackApplicationProtocol = fallbackApplicationProtocol;
    this.clientMode = clientMode;
    this.sessionContext = sessionContext;
}