Java 类io.netty.util.internal.NativeLibraryLoader 实例源码

项目:state-channels    文件:NodeServer.java   
private void configureSsl(NettyServerBuilder builder) throws NoSuchAlgorithmException, CertificateEncodingException, NoSuchProviderException, InvalidKeyException, SignatureException, SSLException {
    NativeLibraryLoader.loadFirstAvailable(ClassLoader.getSystemClassLoader(),
        "netty_tcnative_osx_x86_64",
        "netty_tcnative_linux_x86_64",
        "netty_tcnative_windows_x86_64"
    );
    ECKeyPair ecKeyPair = ethereumConfig.getMainCredentials().getEcKeyPair();
    KeyPair keyPair = CryptoUtil.decodeKeyPair(ecKeyPair);
    SslContextBuilder contextBuilder = SslContextBuilder.forServer(
        keyPair.getPrivate(),
        CryptoUtil.genCert(keyPair)
    );

    builder.sslContext(GrpcSslContexts.configure(contextBuilder).build());
}