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

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


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

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

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

  1. Path taken from RANDFILE environment variable
  2. If HOME environment variable is set then : ${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.


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


just enter this line in the command line :

set RANDFILE=.rnd