Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot add private PEM key to storage #69

Closed
mirik123 opened this issue Jul 26, 2016 · 3 comments
Closed

Cannot add private PEM key to storage #69

mirik123 opened this issue Jul 26, 2016 · 3 comments

Comments

@mirik123
Copy link

mirik123 commented Jul 26, 2016

I receive an error "no importer for key" when try to add private key to keystore.

var privkey = fs.readFileSync('/certs/key.pem');
var jose = require('node-jose');
var keystore = jose.JWK.createKeyStore();
keystore.add(privkey, 'pem')
    .then(function (key) {
        joseprivkey = key;
    },
    function (err) {
        console.error('Failed to create JWE key: ', err);
});

forge.asn1.validate errors:
[ECPrivateKey] Expected type "16", got "3"
[ECPrivateKey] Expected tag class "0", got "64"

type: SEQUENCE, got BITSTRING
tag class: UNIVERSAL, got APPLICATION

certificate:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,DA07AA34F2B9374D582546854D8362F5
XXX
-----END RSA PRIVATE KEY-----
@linuxwolf
Copy link
Member

This method does not supported encrypted private keys. You would need to first decrypt it via other means and then pass the decrypted PEM to add().

@mirik123
Copy link
Author

That means that the private key should be without passphrase?

@linuxwolf
Copy link
Member

That is correct

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

No branches or pull requests

2 participants