Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

[Error: unable to write 'random state' ] #47

Closed
albatarnik opened this issue Apr 25, 2016 · 3 comments
Closed

[Error: unable to write 'random state' ] #47

albatarnik opened this issue Apr 25, 2016 · 3 comments

Comments

@albatarnik
Copy link

albatarnik commented Apr 25, 2016

It's working fine on my local server but on the live server I am getting this error after trying downloading the pass file [Error: unable to write 'random state'], then I can't open the downloaded file.

@danmactough
Copy link

We also experienced this error when trying to use this library in Lambda function on AWS. The reason is that openssl tries to create a file .rnd containing that random state to your HOME directory, which you don't have write access to in the Lambda environment.

Our solution was to monkey patch lib/pass.js at build time to rewrite Line 362:

-  var sign = execFile("openssl", args, { stdio: "pipe" }, function(error, stdout, stderr) {
+  var sign = execFile("openssl", args, { stdio: "pipe", env: { HOME: tmpdir } }, function(error, stdout, stderr) {

tmpdir was a directory we created at build time.

@timoweiss
Copy link

@danmactough good catch! @albatarnik:
You can also set your HOME environment variable before creating your pass.
process.env.HOME = yourTempDir;

Note: you might want to reset the environment variable again after pass creation.

@sharath-yml
Copy link

@timoweiss We had the same issue while trying to run the node server as daemon using upstart or forever-service. This should be put somewhere in the Readme, because many people may end up having this issue trying to use it on production.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants