File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ WORKDIR /etc/letsencrypt
1515
1616COPY entry.sh /usr/local/bin/
1717
18- COPY _keyid.js *.json /opt/
18+ COPY _jwks.js _keyid.js *.json /opt/
1919
2020ENTRYPOINT ["/bin/bash" ]
2121
Original file line number Diff line number Diff line change 1+ const crypto = require ( 'crypto' ) ;
2+ const fs = require ( 'fs' ) ;
3+
4+ // Read in required cert files
5+ const base = process . argv [ 2 ] ;
6+ const pem = fs . readFileSync ( `${ base } .pem` , 'utf8' ) ;
7+ const key = fs . readFileSync ( `${ base } .key` , 'utf8' ) ;
8+ const kid = fs . readFileSync ( `${ base } .kid` , 'utf8' ) . trim ( ) ;
9+
10+ // Generate jwk from pem
11+ const privateKey = crypto . createPrivateKey ( key ) ;
12+ const jwk = privateKey . export ( { format : 'jwk' } ) ;
13+
14+ // Generate x5t thumbprint from pem
15+ const x509 = new crypto . X509Certificate ( pem ) ;
16+ const sha1hash = crypto . createHash ( 'sha1' ) . update ( x509 . raw ) . digest ( ) ;
17+ const x5t = sha1hash . toString ( 'base64url' ) ;
18+
19+ // Remove unnecessary private 'd' property
20+ if ( jwk . d ) {
21+ delete jwk . d ;
22+ }
23+
24+ // Output result
25+ process . stdout . write ( JSON . stringify ( {
26+ keys : [ {
27+ ...jwk ,
28+ use : 'sig' ,
29+ alg : 'ES256' ,
30+ kid,
31+ x5t,
32+ } ] ,
33+ } , null , 2 ) ) ;
Original file line number Diff line number Diff line change @@ -102,6 +102,12 @@ function compute_api_kid {
102102 " ${CERTS} /private/api.${tld} .der" \
103103 > " ${CERTS} /private/api.${tld} .kid"
104104 fi
105+
106+ if [[ -s " ${CERTS} /private/api.${tld} .pem" && -s " ${CERTS} /private/api.${tld} .key" && -s " ${CERTS} /private/api.${tld} .kid" ]]; then
107+ node --no-deprecation /opt/_jwks.js \
108+ " ${CERTS} /private/api.${tld} " \
109+ > " ${CERTS} /private/api.${tld} .jwks.json"
110+ fi
105111}
106112
107113function generate_vpn_dhparams {
You can’t perform that action at this time.
0 commit comments