windows 如何修复openssl中的“无法写入'随机状态'”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12507277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:54:06  来源:igfitidea点击:

How to fix "unable to write 'random state' " in openssl

windowsopenssl

提问by arok

While generating the private key using this command

使用此命令生成私钥时

genrsa -out my-prvkey.pem 1024

It throws the error like below

它抛出如下错误

Loadind 'screen' into random state -done Generating RSA private key,1024 bit long modulus .........................................+++++++ ...........................+++++++++ unable to write 'random state' e is 65537 (0*10001)

将“屏幕”加载到随机状态 -done 生成 RSA 私钥,1024 位长模数 ..................................... ......++++++++ ......................................++++++++ ++ 无法写入“随机状态”e 为 65537 (0*10001)

This makes any problem while creating a public certificate. I'm running this command in windows. Can anyone help me for the fix?

这在创建公共证书时会产生任何问题。我在 Windows 中运行这个命令。任何人都可以帮我修复吗?

回答by sirgeorge

The quickest solution is: set environment variable RANDFILEto path where the 'random state' file can be written (of course check the file access permissions), eg. in your command prompt:

最快的解决方案是:将环境变量RANDFILE设置为可以写入“随机状态”文件的路径(当然检查文件访问权限),例如。在您的命令提示符中:

set RANDFILE=C:\MyDir\.rnd
openssl genrsa -out my-prvkey.pem 1024

More explanations: OpenSSL on Windows tries to save the 'random state' file in the following order:

更多解释:Windows 上的 OpenSSL 尝试按以下顺序保存“随机状态”文件:

  1. Path taken from RANDFILEenvironment variable
  2. If HOMEenvironment variable is set then : ${HOME}\.rnd
  3. C:\.rnd
  1. 取自RANDFILE环境变量的路径
  2. 如果设置了HOME环境变量,则:${HOME}\.rnd
  3. C:\.rnd

I'm pretty sure that in your case it ends up trying to save it in C:\.rnd(and it fails because lack of sufficient access rights). Unfortunately OpenSSL does not print the path that is actually tries to use in any error messages.

我很确定在您的情况下,它最终会尝试将其保存在C:\.rnd 中(并且由于缺乏足够的访问权限而失败)。不幸的是,OpenSSL 不会打印实际尝试在任何错误消息中使用的路径。

回答by alile

It may also be that you need to run the console as an administrator. On windows 7, hold ctrl+shiftwhen you launch the console window.

也可能是您需要以管理员身份运行控制台。在 Windows 7 上,ctrl+shift启动控制台窗口时按住。

回答by eliprodigy

just enter this line in the command line :

只需在命令行中输入这一行:

set RANDFILE=.rnd

回答by konzo

Or this in windows powershell

或者这个在windows powershell中

$env:RANDFILE=".rnd"

回答by Vu Doan

I did not find where the .rnd file is so I ran the cmd as administrator and it worked like a charm.

我没有找到 .rnd 文件的位置,所以我以管理员身份运行 cmd,它就像一个魅力。