Solution to unable to write random state openssl error

Permission issues with a user can trigger OpenSSL errors like "unable to write ‘random state'". This error message is displayed when it occurs.

We have helped our customers a good number of times to solve OpenSSL related issues as part of our Server Support Services.

In this context, we shall look into why this error occurs and how to fix it.

What is behind OpenSSL unable to write 'random state' error?

This error is experienced in the process of using OpenSSL command. It happens due to some factors listed below;

i. User Permission issues when trying to create a file at $HOME/.rnd.
ii. When the user account of the server is not assigned with root level permission in the home directory (.rnd file).
iii. If HOME or RANDFILE is not set, then it will not be recongnized during an OpenSSL process execution.

How to solve OpenSSL unable to write 'random state' error

Fixing this error is easy. To begin, if the .rnd file is owned by root alone and not the user then it is best to delete this file and reissue the openssl command via the command below;

sudo rm ~/.rnd

As stated earlier the root user might be the only permitted owner of the files and to enable the user to have the privileges then simply give ownership to the user as well. You can assign filesystem permissions to the user with the command below;

sudo chown $USER:$USER ~/.rnd

On Windows, you can use the command prompt implementing the "Run As Administrator" mode to resolve unable to write 'random state' error.

Setting the environment variable "RANDFILE" to the path where the "random state" file is writable will also help fix this issue. In this case, you can use the command below;

set RANDFILE=C:\MyDir\.rnd

Finally, exporting the $RANDFLIE environment variable means assigning openssl to use the file in writing random state where no default filename is set.

Need support in fixing OpenSSL errors? We are here.


Best methods to fix "unable to write random state" OpenSSL error.