找不到 TLS ALPN 提供程序;没有可用的 netty-tcnative、Conscrypt 或 Jetty NPN/ALPN

Posted

技术标签:

【中文标题】找不到 TLS ALPN 提供程序;没有可用的 netty-tcnative、Conscrypt 或 Jetty NPN/ALPN【英文标题】:Could not find TLS ALPN provider; no working netty-tcnative, Conscrypt, or Jetty NPN/ALPN available 【发布时间】:2019-07-11 00:24:52 【问题描述】:

您使用的是什么版本的 gRPC?

1.13.1

我正在使用 java 8 来构建一个可执行的 jar。下面是java版本:

$ /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-2~14.04-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

我正在使用 gradle 3.4.1 来生成 jar,如下所示: /opt/gradle-3.4.1/bin/gradle jar -Dorg.gradle.java.home=/usr/lib/jvm/java-1.8.0-openjdk-amd64/ 以下是模块级 build.gradle 文件中定义的依赖项:

dependencies 
  compile files("$TOOLCHAIN_VERSION_DIR/lib/commons-io-2.6.jar")
  compile files("$TOOLCHAIN_VERSION_DIR/lib/grpc-all.jar")
  compile files("$TOOLCHAIN_VERSION_DIR/lib/java-protobuf.jar")
  compile files("$TOOLCHAIN_VERSION_DIR/lib/jetty.jar")
  compile files("$TOOLCHAIN_VERSION_DIR/lib/log4j-core-2.8.jar")
  compile files("$TOOLCHAIN_VERSION_DIR/lib/log4j-slf4j-impl-2.8.jar")
  compile files("$TOOLCHAIN_VERSION_DIR/lib/netty-tcnative-boringssl-static-2.0.20.Final.jar")
  compile files("$TOOLCHAIN_VERSION_DIR/lib/netty-tcnative-2.0.20.Final.jar")
  compile files("$TOOLCHAIN_VERSION_DIR/lib/picocli-3.8.2.jar")
  compile group: 'com.google.guava', name: 'guava', version: '20.0'
  compile files("$TOOLCHAIN_VERSION_DIR/lib/javassist-3.19.0-GA.jar")
  compile project(':annotation')

构建后,我在 AIX7.2 机器上运行 jar,如下所示: /usr/java8_64/jre/bin/java -jar agent-1.0.jar

AIX机器上的java版本如下:

$ /usr/java8_64/jre/bin/java -version           
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 8.0.5.26 - pap6480sr5fp26-20181115_03(SR5 FP26))
IBM J9 VM (build 2.9, JRE 1.8.0 AIX ppc64-64-Bit Compressed References 20181106_401576 (JIT enabled, AOT enabled)
OpenJ9   - fde1d6f
OMR      - d8c3617
IBM      - 5c4a9f0)
JCL - 20181022_01 based on Oracle jdk8u191-b26

但我在运行时遇到以下错误:

Feb 17, 2019 3:11:33 AM io.grpc.netty.GrpcSslContexts defaultSslProvider
INFO: netty-tcnative unavailable (this may be normal)
java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty_tcnative_aix_ppc_64, netty_tcnative_ppc_64, netty_tcnative]
        at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:93)
        at io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:430)
        at io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:97)
        at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:242)
        at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171)
        at io.grpc.netty.GrpcSslContexts.forServer(GrpcSslContexts.java:151)
        at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:456)
        at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:55)
        at com.ankit.agents.AgentMain.<init>(AgentMain.java:91)
        at com.ankit.agents.AgentMain.main(AgentMain.java:132)
        Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_aix_ppc_64
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:205)
                at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:85)
                ... 9 more
        Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_aix_ppc_64.a
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161)
                ... 10 more
                Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative_aix_ppc_64 (Not found in java.library.path)
                        at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
                        at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
                        at java.lang.System.loadLibrary(System.java:565)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:243)
                        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:124)
                        ... 10 more
                        Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative_aix_ppc_64 (Not found in java.library.path)
                                at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
                                at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
                                at java.lang.System.loadLibrary(System.java:565)
                                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
                                at java.lang.reflect.Method.invoke(Method.java:508)
                                at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:263)
                                at java.security.AccessController.doPrivileged(AccessController.java:647)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:255)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:233)
                                ... 11 more
        Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative_ppc_64
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:205)
                at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:85)
                ... 9 more
        Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative_ppc_64.a
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161)
                ... 10 more
                Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative_ppc_64 (Not found in java.library.path)
                        at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
                        at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
                        at java.lang.System.loadLibrary(System.java:565)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:243)
                        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:124)
                        ... 10 more
                        Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative_ppc_64 (Not found in java.library.path)
                                at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
                                at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
                                at java.lang.System.loadLibrary(System.java:565)
                                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
                                at java.lang.reflect.Method.invoke(Method.java:508)
                                at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:263)
                                at java.security.AccessController.doPrivileged(AccessController.java:647)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:255)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:233)
                                ... 11 more
        Suppressed: java.lang.UnsatisfiedLinkError: could not load a native library: netty_tcnative
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:205)
                at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:85)
                ... 9 more
        Caused by: java.io.FileNotFoundException: META-INF/native/libnetty_tcnative.a
                at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:161)
                ... 10 more
                Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative (Not found in java.library.path)
                        at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
                        at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
                        at java.lang.System.loadLibrary(System.java:565)
                        at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                        at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:243)
                        at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:124)
                        ... 10 more
                        Suppressed: java.lang.UnsatisfiedLinkError: netty_tcnative (Not found in java.library.path)
                                at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:1425)
                                at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:1395)
                                at java.lang.System.loadLibrary(System.java:565)
                                at io.netty.util.internal.NativeLibraryUtil.loadLibrary(NativeLibraryUtil.java:38)
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
                                at java.lang.reflect.Method.invoke(Method.java:508)
                                at io.netty.util.internal.NativeLibraryLoader$1.run(NativeLibraryLoader.java:263)
                                at java.security.AccessController.doPrivileged(AccessController.java:647)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibraryByHelper(NativeLibraryLoader.java:255)
                                at io.netty.util.internal.NativeLibraryLoader.loadLibrary(NativeLibraryLoader.java:233)
                                ... 11 more

Feb 17, 2019 3:11:33 AM io.grpc.netty.GrpcSslContexts defaultSslProvider
INFO: Conscrypt not found (this may be normal)
Feb 17, 2019 3:11:33 AM io.grpc.netty.GrpcSslContexts defaultSslProvider
INFO: Jetty ALPN unavailable (this may be normal)
java.lang.ClassNotFoundException: org.eclipse.jetty.alpn.ALPN
        at java.lang.Class.forNameImpl(Native Method)
        at java.lang.Class.forName(Class.java:403)
        at io.grpc.netty.JettyTlsUtil.isJettyAlpnConfigured(JettyTlsUtil.java:64)
        at io.grpc.netty.JettyTlsUtil.getJettyAlpnUnavailabilityCause(JettyTlsUtil.java:75)
        at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:255)
        at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171)
        at io.grpc.netty.GrpcSslContexts.forServer(GrpcSslContexts.java:151)
        at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:456)
        at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:55)
        at com.ankit.agents.AgentMain.<init>(AgentMain.java:91)
        at com.ankit.agents.AgentMain.main(AgentMain.java:132)

Exception in thread "main" java.lang.IllegalStateException: Could not find TLS ALPN provider; no working netty-tcnative, Conscrypt, or Jetty NPN/ALPN available
        at io.grpc.netty.GrpcSslContexts.defaultSslProvider(GrpcSslContexts.java:256)
        at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:171)
        at io.grpc.netty.GrpcSslContexts.forServer(GrpcSslContexts.java:151)
        at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:456)
        at io.grpc.netty.NettyServerBuilder.useTransportSecurity(NettyServerBuilder.java:55)
        at com.ankit.agents.AgentMain.<init>(AgentMain.java:91)
        at com.ankit.agents.AgentMain.main(AgentMain.java:132)

但是,它在 Ubuntu 机器上运行良好。我按如下方式运行 jar: /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java -jar agent-1.0.jar

这里的java版本是:

$ /usr/lib/jvm/java-1.8.0-openjdk-amd64/jre/bin/java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-2~14.04-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

这里有什么问题以及如何解决这个问题?

【问题讨论】:

AIX/PPC 不能使用 Linux/x86 的原生代码。 @LorinczyZsigmond 您知道如何为 AIX 构建所需的本机代码吗?我猜他们是 netty_tcnative_aix_ppc_64、netty_tcnative_ppc_64、netty_tcnative。在 netty 的 github 论坛上,有人告诉我为 AIX 编译 netty,但我不确定如何。这是链接:github.com/netty/netty/issues/8871 【参考方案1】:

可能是:https://github.com/grpc/grpc-java/blob/master/SECURITY.md#tls-with-netty-tcnative-on-boringssl

我在我的 build.gradle 中添加了runtime 'io.netty:netty-tcnative-boringssl-static:2.0.25.Final',它起作用了

【讨论】:

您可以在什么操作系统上运行它? 我在 MacOs Mojave 上运行它【参考方案2】:

就我而言,只需将 Java 版本从 8 更新到 14 即可解决问题(版本 11 也应该没问题)。

如果您使用 Intellij,请确保您的版本更改正常工作。

【讨论】:

以上是关于找不到 TLS ALPN 提供程序;没有可用的 netty-tcnative、Conscrypt 或 Jetty NPN/ALPN的主要内容,如果未能解决你的问题,请参考以下文章

找不到与Java版本匹配的alpn-boot JAR:12.0.2

Python 2.7 中的 TLS ALPN

网络协议之:加密传输中的NPN和ALPN

如何在扭曲的ALPN协商中侦听特定的下一个协议?

HTTPS那些协议:TLS, SSL, SNI, ALPN, NPN

Android grpc 错误:TLS ALPN 协商失败,协议:[grpc-exp,h2]