进行 SSLSocketServer 的最简单方法(运行时生成证书)

发布于 2024-10-06 02:08:06 字数 166 浏览 0 评论 0原文

我想要一种简单的方法来创建 SSLServerSocket。我希望在运行时生成并使用自签名证书,因为数据需要受到保护,但它非常非常安全并不是非常重要。

我找到了有关制作 SSLServerSocket 的教程,但他们假设您有正确的证书。

伪代码、代码示例和简单的段落都是可以接受的答案。

I want a simple way to create a SSLServerSocket. I would like for a self-signed certificate to be generated and used at runtime because the data needs to be protected, but it isn't super important that it is very, very secure.

I found tutorials on making an SSLServerSocket but they assume that you had a proper certificate.

Psuedo-code, code examples and a simple paragraph are all acceptable answers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缺⑴份安定 2024-10-13 02:08:06

最简单的方法可能是调用外部程序。 openssl 是用于许多加密事物的出色工具...制作自签名证书:

openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout www.example.com.pem  -out www.example.com.pem

您可以使用 Runtime.exec() 或使用 运行此类生成流程构建器。

The easiest way to do it may be invoking an external program. openssl is a great tool for many encryption things... Make a self signed cert with:

openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout www.example.com.pem  -out www.example.com.pem

You could run such generation with Runtime.exec() or using a ProcessBuilder.

卸妝后依然美 2024-10-13 02:08:06

通常,如果自签名证书是在服务器每次运行时生成的,则它根本没有任何意义。最好创建一次自签名证书(例如在服务器设置期间),仅此而已。

对于用于保护通信的自签名证书有很好的描述和讨论在此 StackOverflow 主题中。请也阅读它,因为它也解决了您的问题。

Normally self-signed certificate has no sense at all if it's generated on each run of the server. It's better to create a self-signed certificate once (during server setup, for example) and that's all.

There's a good description and discussion of self-signed certificates for securing communication in this StackOverflow topic. Please read it as well, as it addresses your question too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文