feat(TapNodeTools): Add ability to create HTTPS certificates with self-signed option

This commit is contained in:
2024-09-18 18:43:46 +02:00
parent 5a94f116e1
commit c712a9a09c
3 changed files with 13 additions and 2 deletions

View File

@ -16,8 +16,14 @@ class TapNodeTools {
}
public async createHttpsCert(
commonName: string = 'localhost'
commonName: string = 'localhost',
allowSelfSigned: boolean = true
): Promise<{ key: string; cert: string }> {
if (allowSelfSigned) {
// set node to allow self-signed certificates
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
}
// Generate a key pair
const keys = plugins.smartcrypto.nodeForge.pki.rsa.generateKeyPair(2048);