2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 16:56:54 +00:00

TcpServerUtils.pm: generate a better certificate (Forum #124874)

git-svn-id: https://svn.fhem.de/fhem/trunk@25358 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2021-12-20 10:16:10 +00:00
parent a29400c84d
commit a1c57812d8

View File

@ -188,8 +188,31 @@ TcpServer_SetSSL($)
Log 1, "$name: failed to create certreq.txt: $!, falling back to HTTP";
return;
}
print FH "[ req ]\nprompt = no\ndistinguished_name = dn\n\n".
"[ dn ]\nC = DE\nO = FHEM\nCN = home.localhost\n\n";
my $hostname = `hostname`;
chomp($hostname);
print FH << "EOF";
[ req ]
prompt = no
distinguished_name = dn
x509_extensions = ext
[ dn ]
CN = $hostname
O = FHEM
OU = localhost
[ ext ]
basicConstraints=CA:TRUE
extendedKeyUsage = serverAuth
subjectAltName=\@san
[san]
DNS.1=localhost
DNS.2=$hostname
IP.1=127.0.0.1
IP.2=::1
EOF
close(FH);
my $cmd = "openssl req -new -x509 -days 3650 -nodes -newkey rsa:2048 ".