Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a self-signed SSL certificate using OpenSSL (the version that comes with Apache 2.2 + mod_ssl). The OpenSSL binaries are in C:\Web\Apache2.2\bin, and the configuration file I am using is C:\Web\Apache2.2\conf\openssl.cnf. I have executed the following commands:

(I will use newlines to make it more readable.)

openssl req -config ..\conf\openssl.cnf -new -out ..\conf\eduardo.csr
        -keyout ..\conf\eduardo.pem
# Then I entered country code, province, city, etc.
# This step worked correctly.

openssl rsa -in ..\conf\eduardo.pem -out ..\conf\eduardo.key
# Then I entered my pass phrase.

openssl x509 -in ..\conf\eduardo.csr -out ..\conf\eduardo.cert
        -req -signkey ..\conf\eduardo.key -days 1000000

And, when executing the last step, I got the following output:

Loading 'screen' into random state - done
Signature ok
subject=/C=PE/ST=Lima/L=Lima/...
Getting Private Key
unable to write 'random state' <--

What does that error mean, and how can I fix it?

share|improve this question
up vote 1 down vote accepted

openssl tries to write the 'random state' to a file, but the permissions of the directory it is using do not allow to create the file. See:

http://www.openssl.org/support/faq.cgi#USER2

share|improve this answer
    
Where is that directory located? – pyon Feb 14 '11 at 17:16
    
updated openssl link: openssl.org/docs/faq.html#USER2 – Matt Kemp Apr 5 at 0:57
  1. Initially you need to open command prompt in administrator mode.

Then do the following,

  1. cd to_the_certificate_path_folder
  2. set OPENSSL_CONF="C:\OpenSSL-Win32\bin\openssl.cfg"
  3. set RANDFILE="D:\path_to_certs\.rnd" Here if you set RANDFILE path without mentioning .rnd then it given message "Unable to write random state" and openssl didn't create .rnd random state to a file.

  4. C:\OpenSSL-Win32\bin\openssl.exe

  5. OpenSSL> genrsa -out ca.key

It worked for me.

share|improve this answer

For me, on a Windows Server, the solution for this was simply to make sure the command prompt was opened via "Run as Administrator"

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.