自分のドメインで証明書(comodoから)を購入しました。秘密鍵、証明書、およびCAバンドルファイルの3つのファイルがあります。証明書チェーンをNettyサーバーに追加するにはどうすればよいですか?
私はそれを私のApacheサーバ/ mod_sslに追加します。これは完全に動作します。 SSLCertificateFile、SSLCertificateKeyFile、SSLCertificateChainFileの3つの設定パラメータがあるので、簡単な設定ができます。
Nettyをネットワーキングライブラリとして使用して、他のJavaアプリケーションに追加しようとしています。 私のサーバーコードを以下に示します。Config.CERT_FILE_PATH
で
SslContext sslContext = null;
File cert = new File(Config.CERT_FILE_PATH);
File key = new File(Config.KEY_FILE_PATH);
sslContext = SslContextBuilder.forServer(cert, key).build();
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.localAddress(port)
.childOption(ChannelOption.TCP_NODELAY, true)
.childOption(ChannelOption.SO_KEEPALIVE, true)
.childHandler(new WebServerInitializer(sslCtx));
Channel ch = b.bind().sync().channel();
ことConfig.KEY_FILE_PATH
は私のプライベートキーファイルのパスで、私の証明書ファイルのパスです。
しかし、いくつかのブラウザでは証明書のエラーといっても問題はありません(詳細はMac OSではChrome、ブラウザでは私の証明書は信頼できません)。
Nettyのhttpサーバーが証明書の中間証明書をクライアントに送信していないことが判明した場合、証明書のみを送信します(KeyStore Explorerツールによる検証)。
Config.CERT_FILE_PATH
の値をca-bundleファイルのパスに置き換えるか、証明書ファイルの値をca-bundleファイルに追加して新しいファイルを使用しますが、それでも運がないとします。
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLException: Received fatal alert: decrypt_error
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:358)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:230)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.net.ssl.SSLException: Received fatal alert: decrypt_error
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1646)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1614)
at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1780)
at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1075)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:901)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:775)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1135)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1025)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:965)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:327)
... 12 more
ca-bundleで証明書を正しくNettyサーバーに追加するにはどうしたらいいですか?
なぜ、他のブラウザ(WindowsのすべてのブラウザとMacのchromiumベースのブラウザを除くすべてのブラウザも)が自分のエラーサーバーで動作するのはなぜですか?
私はこれらの証明書を間違った順序で連結していますが、正しい順序は証明書チェーンの前の証明書サーバーです – Viet