joyent/node — pull request #6301 by thomseddon (2013-10-04 12:08:16+00:00)
Title: Use passphrase protected private key to create signature

For example running:

```js
var sig = crypto.createSign('RSA-SHA256').update('psst').sign(pk,'hex');
```

Results in a prompt:
```
Enter PEM pass phrase:
```

I don't think there is any possible way to pass in a passphrase as `NULL` is always passed: https://github.com/joyent/node/blob/master/src/node_crypto.cc#L2628

I'm really keen to build this myself but I would like some guidance on:

**1) Is this a valid issue for which a solution should be provided?**

I think it is, working around it requires manually decrypting the passphrase with open ssl everytime you start your app, e.g. child process `openssl rsa -in /path/to/private_key -passin pass:insert_password_here` which is lame.

**2) How would this functionality be best modelled?**

My first thoughts are something like:
a)
```js
crypto.createSign('RSA-SHA256').update('psst').sign({ key: pk, passphrase: 'password' },'hex');
```

b)
```js
crypto.createSign('RSA-SHA256').update('psst').sign(pk, 'password', 'hex');
```

Thanks, like I say, keen to build this (as first node core contrib) so guidance much appreciated