在WebSocket中添加ssl遇到的问题

11 篇文章 3 订阅

在WebSocket中添加ssl遇到的问题

[toc]
做个记录

错误日志及解决方案

可以从复制下自己的错误,在网页中找下,看下能不能找到。

// System.setProperty(“javax.net.debug”, “all”);

问题1:javax.net.ssl.SSLHandshakeException: No appropriate protocol

io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

方案:权限问题

过一阵瞎搞,最后才发现是因为jdk1.8版本导致SSL调用权限上有问题。
解决办法:找到jdk 1.8安装目录,找到jdk里面的lib\security 下面有个java.security。找到对应的SSLv3,删除掉,重启项目就好了。(删掉SSLv3就是允许SSL调用)

问题2:protocol_version、 ERR_CERT_COMMON_NAME_INVALID、 ERR_CERT_AUTHORITY_INVALID

Caused by: javax.net.ssl.SSLException: Received fatal alert: protocol_version
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLException: Received fatal alert: protocol_version
Caused by: javax.net.ssl.SSLException: Received fatal alert: protocol_version

方案:网页客户端需要信任证书

internal_error

问题3:io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record:

io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record:

方案:

客户端中pipeline.addLast(“ssl”, new SslHandler(sslEngine));

问题4:PKIX path building failed、General SSLEngine problem、unable to find valid certification path to requested target

018-08-17 15:35:55.250 DEBUG io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker13 - WebSocket version 13 client handshake key: txOihqp44yIRBkIiOqYQzA==, expected response: cR25d0JOMq6RBX9igrELEfGejKA=
2018-08-17 15:35:55.820 INFO com.lizhaoblog.server.channel.websocket.WebSocketClientHandlerTest - 异常发生
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: General SSLEngine problem

Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
… 26 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:392)
… 32 more

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

方案:

  • 自己生成的证书,没有经过验证,jdk不认可
    • 启动服务器
    • 使用SSLCre请求生成一个jssecacerts
    • 将jssecacerts替换成D:\Program Files\Java\jdk1.8.0_171\jre\lib\security下的cacerts
    • 要记得改名字
      “`
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值