Browse code

kamclt: subcommand tls gen-certs

- generate self signed certificate in current directory

Daniel-Constantin Mierla authored on 20/10/2021 18:39:17
Showing 2 changed files
... ...
@@ -2881,6 +2881,16 @@ tls_ca() {
2881 2881
 		minfo "Certificate is locate at $USER_DIR/$USER-cert.pem "
2882 2882
 		minfo "CA-List is locate at $USER_DIR/$USER-calist.pem "
2883 2883
 
2884
+	elif [ "$1" = "gen-certs" ] ; then
2885
+		mecho "Generating self signed certificates"
2886
+		if [ -z "$CERTDAYS" ] ; then
2887
+			CERTDAYS=365
2888
+		fi
2889
+		if [ -n "$2" ] ; then
2890
+			openssl req -x509 -newkey rsa:4096 -nodes -subj "/CN=${2}" -keyout kamailio-selfsigned.key -out kamailio-selfsigned.pem -days ${CERTDAYS}
2891
+		else
2892
+			openssl req -x509 -newkey rsa:4096 -nodes -keyout kamailio-selfsigned.key -out kamailio-selfsigned.pem -days ${CERTDAYS}
2893
+		fi
2884 2894
 	else
2885 2895
 		merr "unknown TLS command $1"
2886 2896
 		usage_tls
... ...
@@ -381,9 +381,10 @@ usage_tls() {
381 381
 	mecho " -- command 'tls'"
382 382
 	echo
383 383
 cat <<EOF
384
- tls rootCA [<etcdir>] .......... creates new rootCA
384
+ tls rootCA [<etcdir>] ............ creates new rootCA
385 385
  tls userCERT <user> [<etcdir>] ... creates user certificate
386
- default <etcdir> is $ETCDIR/tls
386
+ * default <etcdir> is $ETCDIR/tls
387
+ tls gen-certs [<domain>] ......... generate self signed certificate
387 388
 EOF
388 389
 }
389 390