Skip to content

Cannot add private PEM key to storage #69

Closed

Description

@mirik123

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-----

Activity

  1. linuxwolf commented on Jul 28, 2016

    @linuxwolf
    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().

  2. mirik123 commented on Jul 29, 2016

    @mirik123
    Author

    That means that the private key should be without passphrase?

  3. linuxwolf commented on Aug 1, 2016

    @linuxwolf
    Member

    That is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions