无法将/root/.rnd加载到RNG中

39

我想使用Windows Open SSL生成服务器证书。

当我运行此命令时,出现了错误。 我该怎么办?

命令:

:
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt

错误:

无法将./.rnd加载到RNG中10504:错误:2406F079:随机数生成器:RAND_load_file:无法打开文件:crypto\rand\randfile.c:98: 文件名=./.rnd

我也尝试查找openssl配置文件,但没有,我没有那个文件。

3个回答

89

尝试删除或注释掉/etc/ssl/openssl.cnf文件中的RANDFILE = $ENV::HOME/.rnd行。


如果我没有那个文件怎么办? - Asma
不使用那个文件,移除该选项。 - InYeopTTi

17

在Ubuntu 18.04上使用OpenVPN Road Warrior脚本时,我遇到了这个问题。

解决方案是手动创建文件,在那之后脚本就可以完美地工作了。

首先进入正确的目录。然后通过调用openssl并告诉它使用rand生成随机字节,并使用-writerand选项写入名为.rnd的文件来自己创建文件,如下所示:

cd /etc/openvpn/easy-rsa/pki
openssl rand -writerand .rnd

更多信息请参阅openssl手册页面 https://www.openssl.org/docs/man1.1.1/man1/openssl-rand.html


2
这似乎是最简单的解决方案,对我有效!我不太想修改一个我不太理解的配置文件。 - Wellspring

8

原因: “-rand”选项默认告诉程序使用随机的.rnd文件,但是用户可能会遇到不存在该文件的问题。

解决方法: 添加“-writerand”选项可以在文件不存在时自动生成.rnd文件。

例如:

root@CentOS:/usr/local/etc/openldap/private # openssl genrsa -rand -genkey -out cert.key 2048
Can't load -genkey into RNG
546983936:error:2406F079:random number generator:RAND_load_file:Cannot open file:/usr/src/crypto/openssl/crypto/rand/randfile.c:98:Filename=-genkey

在添加了“-writerand”之后,
root@CentOS:/usr/local/etc/openldap/private # openssl genrsa -writerand -genkey -out cert.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
...........................+++++
..............+++++
e is 65537 (0x010001)
root@CentOS:/usr/local/etc/openldap/private # 

我自己也会再次遇到这个错误。当然我会先去查看 StackOverflow(哈哈 R6000)!!!


1
参考: 从这里得到的灵感:https://github.com/node-opcua/node-opcua-pki/issues/7 - Biddut Mitra
由于某种原因,再次运行此命令会导致 OP 报告的错误:( )。 - zaf187

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接