I'm trying to convert a .crt string into a .der certificate and save it into Redis. I'm try to replicate the following steps with Nodejs
openssl x509 -outform der -in certificate.pem -out certificate.der
openssl rsa -outform DER -in key.pem -out key.der
redis-cli -x HMSET domain:testsite1.com cert < testsite1.com.der
redis-cli -x HMSET domain:testsite1.com key < testsite1.com.key.der
The .crt string looks like this
-----BEGIN CERTIFICATE-----
XXXXXXXXXXX
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
XXXXXXXXXX
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
XXXXXXXXX
-----END CERTIFICATE-----
This is my failed attempt using node-forge
npm and redis
.
var certDER = forge.asn1.toDer(forge.pki.certificateToAsn1('/opt/resty/ssl/*.ngdeploy.com.chained.crt',{encoding: 'utf8'}));
REDIS.hmset('test','cert',certDER);
I tried Googling for solutions but I didn't find any for converting .crt string to .der binary. I'm looking for a Node.js solution and not an OpenSSL solution. Please advise.