简体   繁体   English

同一台机器上具有相同证书的两个服务之间的相互认证

[英]Mutual authentication between two services with same certificate on the same machine

I've a simple spring boot service ( service A ) that has some REST API exposed.我有一个简单的 spring 引导服务( service A ),它暴露了一些 REST API。 For adding https support, I used the same certificate that is issued to another service ( service B ) present in the same box.为了添加 https 支持,我使用了颁发给同一框中的另一个服务( service B )的相同证书。 Here's my application.properties file这是我的 application.properties 文件

server.ssl.enabled=true
server.ssl.client-auth=need
server.ssl.key-store=keystore.jks
server.ssl.key-store-password=password
server.ssl.key-store-type=JKS
server.ssl.trust-store-password=password
server.ssl.trust-store=keystore.jks
server.ssl.trust-store-type=JKS

This seems to be working when the connection to service A is made from a client that's not service B .当与service A的连接是从不是service B的客户端建立时,这似乎有效。 I enabled mutual authentication between services so that client cert is validated.我启用了服务之间的相互身份验证,以便验证客户端证书。 When a request is being made from B to A , I am getting error当从BA发出请求时,我收到错误

javax.net.ssl.SSLHandshakeException: Received fatal alert: bad_certificate
        at sun.security.ssl.Alert.createSSLException(Alert.java:131)
        at sun.security.ssl.Alert.createSSLException(Alert.java:117)

After enabling the ssl debug, I found this error to be causing this启用 ssl 调试后,我发现此错误是导致此问题的原因

upcoming handshake states: server finished[20]
*** Certificate chain
<Empty>
***
https-jsse-nio-8090-exec-4, fatal error: 42: null cert chain

I checked and re-checked that the keystore and truststore are set properly, yet, no luck.我检查并重新检查密钥库和信任库是否设置正确,但没有运气。 Is there a way I can make this work with server and client having same certificate?有没有办法可以让具有相同证书的服务器和客户端一起工作? Appreciate any pointers on how I can make it work (with the same cert) as I have been struggling with this for a week.感谢我如何使它工作(使用相同的证书)的任何指示,因为我已经为此苦苦挣扎了一周。

Does your JKS contain the whole chain?您的 JKS 是否包含整个链条? If you look inside, do you have the whole chain all the way to the root certificate?如果你往里看,你有没有一直到根证书的整个链条?

The error is telling you that it cant find the chain.错误告诉你它找不到链。 Your certificate is probably self-signed?您的证书可能是自签名的? or your JKS doesnt have the full chain.或者你的 JKS 没有完整的链条。

See similar Stackoverflow question: CamelJettyWebSocketServer, fatal error: 42: null cert chain查看类似的 Stackoverflow 问题: CamelJettyWebSocketServer, fatal error: 42: null 证书链

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM