Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save x-yuri/5c6b9155fe9ae813a6ed04e0bd364732 to your computer and use it in GitHub Desktop.
Save x-yuri/5c6b9155fe9ae813a6ed04e0bd364732 to your computer and use it in GitHub Desktop.
alpine linux <= 3.8: let's encrypt certs doesn't work

Alpine Linux <= 3.8: Let's Encrypt certs doesn't work

See this.

a.js:

const https = require('https');
https.get({host: 'registry.bower.io'}, res => {
    console.log(res.statusCode);
}).on('error', e => {
    console.log(e);
});

b.js:

const https = require('https');
https.get({host: 'registry.bower.io', rejectUnauthorized: false}, res => {
// https.get({host: 'registry.bower.io', agent: https.Agent({rejectUnauthorized: false})}, res => {
    console.log(res.statusCode);
}).on('error', e => {
    console.log(e);
});

c.js:

const https = require('https');
const fs = require('fs');
const ca = fs.readFileSync('a.pem');
https.get({host: 'registry.bower.io', ca: ca}, res => {
// https.get({host: 'registry.bower.io', agent: https.Agent({ca: ca})}, res => {
    console.log(res.statusCode);
}).on('error', e => {
    console.log(e);
});
$ docker run --rm -it ruby:2.3.8-alpine3.8 sh
/ # apk add curl nodejs
/ # curl https://letsencrypt.org/certs/isrgrootx1.pem -o a.pem
/ # node a.js
{ Error: certificate has expired
    at TLSSocket.<anonymous> (_tls_wrap.js:1116:38)
    at emitNone (events.js:106:13)
    at TLSSocket.emit (events.js:208:7)
    at TLSSocket._finishInit (_tls_wrap.js:643:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:473:38) code: 'CERT_HAS_EXPIRED' }
/ # node b.js
302
/ # node d.js
302
/ # NODE_TLS_REJECT_UNAUTHORIZED=0 node a.js
302
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment