endpoint.setSNIContexts(entries[, options])
entriesobject 一个将主机名映射到 TLS 身份选项的对象。每个条目必须包括keys和certs。optionsobjectreplace<boolean> 如果使用true,将替换整个 SNI 映射。如果使用false(默认),将条目合并到现有映射中。
替换或更新此端点的 SNI TLS 上下文。这允许在不重启端点的情况下更改特定主机名使用的 TLS 身份(密钥/证书)。现有会话不受影响——只有新会话会使用更新的上下文。
🌐 Replaces or updates the SNI TLS contexts for this endpoint. This allows changing the TLS identity (key/certificate) used for specific host names without restarting the endpoint. Existing sessions are unaffected — only new sessions will use the updated contexts.
endpoint.setSNIContexts({
'api.example.com': { keys: [newApiKey], certs: [newApiCert] },
});
// Replace the entire SNI map
endpoint.setSNIContexts({
'api.example.com': { keys: [newApiKey], certs: [newApiCert] },
}, { replace: true });