You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since node v20.18.0 and v22.9.0 and newer, you no longer need nginx/haproxy in front in order to do tls-alpn-01 issuance/renewal. Starting with these node versions, you can set the key and certificate for a connection inside the ALPNCallback in the https server config object, which allows you to do the tls-alpn-01 validation completely within node. Example:
letsslRenew=null;// First define the `ALPNCallback` in your HTTPS server configconsthttpsServer=https.createServer({// ...ALPNCallback: function({ servername, protocols }){if(!Array.isArray(protocols))return;lethttp10;lethttp11;letacme;for(constprotocolofprotocols){switch(protocol){case'http/1.0':
http10=protocol;break;case'http/1.1':
http11=protocol;break;case'acme-tls/1':
acme=protocol;break;}}if(acme&&sslRenew?.type==='tls-alpn-01'){this.setKeyCert(sslRenew.ctx);returnacme;}returnhttp11||http10||undefined;},});// Then somewhere else where you are requesting a new certificate// via `auto()`:asyncfunctionrenewCert(){// ...constcert=awaitclient.auto({// ...challengeCreateFn: async(authz,challenge,keyAuthorization)=>{consttype=challenge.type;switch(type){case'http-01':
// Handling http-01 is outside the scope of this examplesslRenew={
type,url: `/.well-known/acme-challenge/${challenge.token}`,data: keyAuthorization,};break;case'tls-alpn-01': {const[alpnKey,alpnCert]=awaitacme.crypto.createAlpnCertificate(authz,keyAuthorization);sslRenew={
type,ctx: tls.createSecureContext({key: alpnKey,cert: alpnCert,minVersion: 'TLSv1.2',}),};break;}}},challengeRemoveFn: (authz)=>{sslRenew=null;},});// Store key and obtained cert somewhere ...// Update the HTTPS server to use them ...httpsServer.setSecureContext({
key,
cert,minVersion: 'TLSv1.2',});}
The text was updated successfully, but these errors were encountered:
Since node v20.18.0 and v22.9.0 and newer, you no longer need nginx/haproxy in front in order to do tls-alpn-01 issuance/renewal. Starting with these node versions, you can set the key and certificate for a connection inside the
ALPNCallback
in the https server config object, which allows you to do the tls-alpn-01 validation completely within node. Example:The text was updated successfully, but these errors were encountered: