17

When I run:

openssl genrsa -out mykey.key 2048

I get the following error:

unable to write 'random state'
    e is 65537 (0x10001)

My googling suggests this is some kind of Vista permissions issue. How can I allow Vista to write this file or how can I configure openssl to get round it?

Iain
  • 9,432
  • 11
  • 47
  • 64
  • possible duplicate of [Using openssl what does "unable to write 'random state'" mean?](http://stackoverflow.com/questions/94445/using-openssl-what-does-unable-to-write-random-state-mean) – jww Aug 13 '14 at 12:59

5 Answers5

62

The root issue is that the RANDFILE variable in the OpenSSL configuration file is ignored on Windows. This has been a long-standing problem that continues to exist as of the OpenSSL v1.0a release, regardless of whether the target Windows platform is x86 or x64.

There is a delightfully simple solution, though. Merely use a regular environmental var to set the RANDFILE value, like

set RANDFILE=.rnd

Because this value is ephemeral, it must be re-issued for every new DOS box, or scripted in a batch file.

judoman
  • 922
  • 9
  • 10
4

I found this that might help: Using OpenSSL what does "unable to write 'random state'" mean?

also, here: http://adamyoung.net/OpenSSL-unable-to-write-random-state

there is a suggestion here http://www.mail-archive.com/openssl-users@openssl.org/msg51344.html on how to get it working in vista.

find the location of cmd.exe, right click and run as administrator

Community
  • 1
  • 1
John Boker
  • 82,559
  • 17
  • 97
  • 130
3

I had the same issue but for Windows 7. Easily solved, I created a system Environment Variable called HOME and set it to the directory I wanted my .rnd file in. This solved the issue because OpenSSL didn't know where my .rnd file was (because I didn't have one) and it didn't know where to put it if it was to create it. As soon as I set my environment variable HOME with a directory (c:\ is fine!) I reran my key generation in OpenSSL and it worked straight off. To verify, I checked the key I had created and it had proper content. I also checked the directory I set my HOME environment variable to, and lo and behold a .rnd file was sat there! Hope this helps someone :-)

Lee-anne
  • 31
  • 1
0

The issue is that the script is missing some access rights or cant find the file.

The solution:

Create a system variable with the name RANDFILE and the value %USERPROFILE%.rnd

Notice the %USERPROFILE%, is a system variable that automatic inserts the path to your user profile.

0

Add a HOME variable into your environment variables.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
zengkun100
  • 53
  • 1
  • 5