Openssl 自签名证书出现随机数错误

Openssl 自签名证书出现随机数错误,openssl,self-signed,Openssl,Self Signed,我一直在尝试创建一个自签名证书,但我不断收到一个与随机数生成器相关的错误。我在终端中输入了以下内容: openssl req -x509 -days 365 -sha256 -newkey rsa:4096 -keyout mycert.pem -out mycert.pem 然后,系统会提示我输入信息。我很好地通过了,但当我按enter键时,我出现以下错误: Cannot write random bytes: 139680915939776:error:2407007A:random n

我一直在尝试创建一个自签名证书,但我不断收到一个与随机数生成器相关的错误。我在终端中输入了以下内容:

openssl req -x509 -days 365 -sha256 -newkey rsa:4096 -keyout mycert.pem -out mycert.pem
然后,系统会提示我输入信息。我很好地通过了,但当我按enter键时,我出现以下错误:

Cannot write random bytes:

139680915939776:error:2407007A:random number generator:RAND_write_file:Not a regular file:crypto/rand/randfile.c:163:Filename=/home/user/.rnd

通过使用以下代码替换/usr/share/dovecot/dovecot openssl.cnf内容解决了此问题:

[ req ]
default_bits = 2048
encrypt_key = yes
distinguished_name = req_dn
x509_extensions = cert_type
prompt = no

[ req_dn ]
# country (2 letter code)
#C=FI

# State or Province Name (full name)
#ST=

# Locality Name (eg. city)
#L=Helsinki

# Organization (eg. company)
#O=Dovecot

# Organizational Unit Name (eg. section)
OU=IMAP server

# Common Name (*.example.com is also possible)
CN=imap.example.com

# E-mail contact
emailAddress=postmaster@example.com

[ cert_type ]
nsCertType = server

可能是不允许在用户运行命令的情况下编写
/home/user/.rnd


您可能需要检查您的访问权限,或者检查是否存在
/home/user

我对覆盆子pi3I有完全相同的问题。我在阅读时得出了这个结论。