数字签名服务器上的私钥存储在哪里?
我正在开发一个客户端服务器应用程序,需要在发送到客户端之前使用私钥对某些文件进行签名。然后,客户端将使用公钥验证签名。因此,私钥需要始终位于服务器上并且可由服务器应用程序读取。
问题是我想知道在哪里存储我的私钥,这样在服务器受到威胁时更安全,不会被泄露。
我应该将其存储在数据库中还是应该将其存储为文件并使用文件权限来控制?
谢谢。
I am developing a client-server application that requires some files to be signed using the private key before sending to the client. The client will then verify the signature using the public key. Therefore, the private key will need to be on the server at all time and readable by the server application.
The problem is that I was wondering where to store my private key that is more secure from being leaked in case the server is compromised.
Should I store it in the database or should I store it as a file and use file permission to control?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
选项是使用以不同用户身份运行的 setuid 二进制文件来进行证书签名。
其他用户将具有对该密钥的读取访问权限,但“普通”应用程序服务器用户不会具有读取访问权限。因此,如果有人破坏了应用程序服务器的帐户,他们只能签署任意证书,而无法窃取 CA 私钥。
另一种可能性是使用某种 RPC 机制将签名请求传递给以另一个用户身份运行的另一个进程(可能在另一个主机上)。或者同一主机上的另一个虚拟机(但不在应用服务器计算机内)。
这些方法中的任何一种都只是减少了妥协的影响,但它仍然很糟糕。
Option option is to use a setuid binary which runs as a different user to do the certificate signing.
This other user would have read-access to the key, but the "Normal" app-server user would not have read-access. Therefore if someone compromised the app server's account, they would only be able to sign arbitrary certificates, not steal the CA private key.
Another possibility would be to have some RPC mechanism to pass the signing request to another process running as another user, possibly on another host. Or another VM on the same host (but not inside the app server machine).
Any of these approaches just reduce the impact of a compromise, but it's still bad.
如果密钥存储在服务器本身上,那么如果该服务器受到损害,它将被发现。存储在数据库/文件中不太可能阻止这种情况 - 大多数对服务器的入侵都是通过其运行的服务发生的。
一种选择是将私钥存储在称为硬件安全模块(HSM)的单独硬件模块中。 HSM 根据请求生成签名,但不会向服务器泄露私钥。如果服务器受到威胁,他们可以在访问期间让服务器对文件进行签名,但无法获取密钥本身,并且必须保留对服务器的访问权限才能继续生成签名。对于不频繁的应用,智能卡可以充当简单的 HSM。
If the key is stored on the server itself, then if that server is compromised it will be found. Storing in a DB/files are not likely to prevent this - most breaks in to a server happen through the services it operates.
One option is to store private keys in a separate hardware module called a Hardware Security Module, or HSM. The HSM generates signatures on request, but will not disclose the private key to the server. If the server is compromised, they can get it to sign files for the duration of their access, but can't obtain the key itself and must retain access to the server to continue generating signatures. For infrequent applications, a smart card can serve as a simple HSM.