简体   繁体   English

Spring 启动 SSL 客户端-服务器通信

[英]Spring Boot SSL Client-Server Communication

I am rather new to Spring Boot and SSL.我对 Spring Boot 和 SSL 比较陌生。 I have developed a SSL rest web server with server keystore , private key , server CA and that correctly handles mutual X.509 certificate authentication.我开发了一个 SSL rest web 服务器与服务器密钥库私钥服务器 CA并正确处理相互 X.509 证书身份验证。 I have tested, that works HTTPS requests with Postman and also Python Client and everything working correctly, both the server and client are successfully exchanging and validating each others certificates.我已经测试过,HTTPS 请求与 Postman 以及 Python 客户端和一切正常工作,服务器和客户端都成功地交换和验证彼此的证书。

But my scenario is little bit different,但我的情况有点不同,

I have created and connected one Postgresql database to my spring boot application and I have created entities of tables with specific ID numbers and also REST endpoints which you can create, get entity etc.我已经创建了一个 Postgresql 数据库并将其连接到我的 spring 启动应用程序,并且我已经创建了具有特定 ID 号的表的实体以及 REST 端点,您可以创建这些端点等,

So my scenario is following;所以我的情况如下;

  1. Python Client comes with specific ID number and makes a request to one REST Endpoint which is available for everybody (permitted by server). Python 客户端带有特定的 ID 号,并向一个 REST 端点发出请求,该端点可供所有人使用(服务器允许)。
  2. Spring Boot Server checks that ID number in database and creates a Client Certificate to the Python Client (which I am stucked right now.) and sends this certificate to Client. Spring 引导服务器检查数据库中的 ID 号,并为 Python 客户端(我现在卡住了。)创建客户端证书并将此证书发送给客户端。
  3. After Sending the Client Certificate, Client can use it and communicate Server with Certificate发送客户端证书后,客户端可以使用它并与证书通信服务器

So question is following;所以问题来了;

Is that possible to create a client certificate in runtime in java?是否可以在 java 的运行时创建客户端证书? If yes, how I can create it and send back to client?如果是,我如何创建它并发送回客户?

Thank you for your time and response.感谢您的时间和回复。

I have found the solution.我找到了解决方案。 If somebody needs similar solution, you can the following steps;如果有人需要类似的解决方案,您可以执行以下步骤;

  1. Create public endpoint in spring boot which you can take the given id number在 spring 引导中创建公共端点,您可以使用给定的 ID 号
  2. Compare with your database and if it id number existed call an.sh file (use process)与您的数据库进行比较,如果它存在 id 号,则调用 an.sh 文件(使用过程)
  3. In this.sh file, use openssl commands to generate a key, remove the passphrase from the key (if you used it), create a client certificate request and finally sign the certificate.在此.sh 文件中,使用 openssl 命令生成密钥,从密钥中删除密码(如果您使用过),创建客户端证书请求并最终签署证书。
  4. Finally send this signed certificate and private key back to client.最后将此签名证书和私钥发送回客户端。

After all, your client can use your signed certificate with private key and use your secured endpoints.毕竟,您的客户可以将您的签名证书与私钥一起使用并使用您的安全端点。

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

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