NodeJS & SSL - “bad password read”

后端 未结 3 1817
执笔经年
执笔经年 2020-12-15 15:40

Node is failing to create a secure context for SSL communications.

Specifically, I\'m trying to get remote notifications to work on iOS. I use a module, called node-

相关标签:
3条回答
  • 2020-12-15 15:48

    This is because you've specified a passphrase when generating the cert. This is a password that must be supplied by anyone wanting to use it.

    Adding a passphrase field to the credentials solves the problem.

    var credentials = {
        key: fs.readFileSync('XXX.key', 'utf8'),
        cert: fs.readFileSync('XXX.crt', 'utf8'),
        passphrase: 'XXXX'
    }
    
    var httpsServer = https.createServer(credentials, app);
    
    0 讨论(0)
  • 2020-12-15 16:03

    The following command will generate an unencrypted key, so you won't need to provide a passphrase:

    openssl rsa -in yourKey.key -out newKey.key
    

    This command will prompt you for the passphrase.

    0 讨论(0)
  • 2020-12-15 16:04

    Use these to generate pem.

    openssl genrsa -out server-key.pem 1024 openssl req -new -key server-key.pem -out server-csr.pem openssl x509 -req -in server-csr.pem -signkey server-key.pem -out server-cert.pem

    0 讨论(0)
提交回复
热议问题