ssl - 使用keytool时如何避免/dev/urandom

标签 ssl keytool

我们在 Linux、Solaris 和 AIX 平台上使用 tomcat、weblogic、websphere、apache(主要是 java)。对于加密,我们使用 SSL。要生成私钥/公钥对,我们使用 keytool。有关 java keytool 的文章建议我们避免使用/dev/urandom 作为熵设备。鉴于/dev/urandom 是默认值,我们如何在不使用/dev/urandom 的情况下创建私钥/公钥对?

最佳答案

感兴趣的文件位于您的 JRE lib/security 文件夹中,名为 java.security。在其中您会发现以下行:

securerandom.source=file:/dev/urandom

并且文件中有描述其行为的注释。如果需要,您可以将其切换为使用 /dev/random(这更安全,但由于熵问题可能需要很长时间):

#
# Select the source of seed data for SecureRandom. By default an
# attempt is made to use the entropy gathering device specified by 
# the securerandom.source property. If an exception occurs when
# accessing the URL then the traditional system/thread activity 
# algorithm is used. 
#
# On Solaris and Linux systems, if file:/dev/urandom is specified and it
# exists, a special SecureRandom implementation is activated by default.
# This "NativePRNG" reads random bytes directly from /dev/urandom.
#
# On Windows systems, the URLs file:/dev/random and file:/dev/urandom
# enables use of the Microsoft CryptoAPI seed functionality.
#
securerandom.source=file:/dev/urandom
#
# The entropy gathering device is described as a URL and can also
# be specified with the system property "java.security.egd". For example,
#   -Djava.security.egd=file:/dev/urandom
# Specifying this system property will override the securerandom.source 
# setting.

你可以看到更多关于Java policy files here in the Oracle docs的信息

这是关于 overriding default Java security 的简短教程还有

关于ssl - 使用keytool时如何避免/dev/urandom,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24175157/

相关文章:

c# - 无法建立 SSL 连接,请参阅内部异常

java - 如何为 java keytool 设置默认语言?

ruby-on-rails - 在开发模式下设置 ssl on rails 4 app

php - GMAIL imap_open 远程规范无效 (errflg=2)

java - 导入证书或链时java keytool命令的区别

ssl - 如何从现有证书 (abc.crt) 和 abc.key 文件创建 keystore ?

java - 无法找到请求目标的有效证书路径 - 即使在导入证书后也会出现错误

java - 使用系统证书签署 apk

java - Oracle JDBC 瘦驱动程序 SSL

wpf - 如何检查基于 WPF 的胖客户端应用程序是否使用传输层安全性 (TLS)