Skip to content

Commit 8160cbc

Browse files
committed
Add self-signed certificates to build inter-active menu
Signed-off-by: Richard T Bonhomme <[email protected]>
1 parent afe9291 commit 8160cbc

File tree

1 file changed

+82
-4
lines changed

1 file changed

+82
-4
lines changed

easytls

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ Use the 'help' command above to get full usage details.
7777
inline :Inter-active menu to build Inline files
7878
remove :Inter-active menu to remove TLS keys and Inline files
7979
script :Inter-active menu to configure Server scripts
80+
self-sign-server
81+
self-sign-client
8082
build-tls-auth
8183
build-tls-crypt
8284
build-tls-crypt-v2-server <server_filename_base>
@@ -285,7 +287,7 @@ cmd_help()
285287
self-sign-server
286288
Build a self signed server certificate and key." ;;
287289
ssc|self-sign-client) text="
288-
self-sign-server
290+
self-sign-client
289291
Build a self signed client certificate and key." ;;
290292

291293
options)
@@ -4184,12 +4186,12 @@ build_self_sign ()
41844186

41854187
# Certificate type
41864188
case "${cert_type}" in
4187-
server)
4189+
[sS]erver)
41884190
# Certificate extension: TLS Web Server
41894191
EASYTLS_EKU="serverAuth"
41904192
openssl_eku="-addext extendedKeyUsage"
41914193
;;
4192-
client)
4194+
[cC]lient)
41934195
# Certificate extension: TLS Web Server
41944196
EASYTLS_EKU="clientAuth"
41954197
openssl_eku="-addext extendedKeyUsage"
@@ -4595,6 +4597,8 @@ interactive_build ()
45954597
[2] TLS-Crypt-V1 key - Basic TLS-crypt-v1 pre-shared key
45964598
[3] TLS-Crypt-V2 key for Server - Advanced TLS-Crypt-v2 Server key
45974599
[4] TLS-Crypt-V2 key for Client - Advanced TLS-Crypt-v2 Client key
4600+
[5] Self-signed server - Server X509 certificate and key
4601+
[6] Self-signed client - Client X509 certificate and key
45984602
45994603
Select the type of TLS-key to build:'
46004604
interactive_question
@@ -4810,6 +4814,18 @@ interactive_build ()
48104814

48114815
return 0
48124816
;;
4817+
5) # Self-signed server
4818+
cert_type='Server'
4819+
interactive_selfsign_CN
4820+
interactive_selfsign_PW
4821+
build_self_sign "${cert_type}" "${common_name}"
4822+
;;
4823+
6) # Self-signed client
4824+
cert_type='Client'
4825+
interactive_selfsign_CN
4826+
interactive_selfsign_PW
4827+
build_self_sign "${cert_type}" "${common_name}"
4828+
;;
48134829
*) # Other value -> Quit
48144830
"$EASYTLS_PRINTF" '\n%s\n' ' Quit!'
48154831
;;
@@ -5594,7 +5610,69 @@ interactive_scripts ()
55945610

55955611
} # => interactive_scripts ()
55965612

5597-
# Set commonName
5613+
# Set commonName and verify this cert does not exist
5614+
interactive_selfsign_CN ()
5615+
{
5616+
unset common_name
5617+
ia_question_help='
5618+
* This field only requires the certificate commonName,
5619+
it does not require the complete file name.'
5620+
5621+
while :
5622+
do
5623+
ia_question_text="
5624+
Enter the commonName of your * ${cert_type} * certificate:"
5625+
interactive_question
5626+
[ -n "${ia_answer}" ] || continue
5627+
common_name="${ia_answer}"
5628+
cert_file="${EASYTLS_PKI}/${common_name}.crt"
5629+
[ -f "${cert_file}" ] || {
5630+
cmd_line="${cmd_line} ${common_name}"
5631+
break
5632+
}
5633+
ia_question_text=" Press enter to continue.."
5634+
printf "\n%s\n\n" " A certificate named ${common_name} already exists!"
5635+
interactive_wait_for_answer
5636+
done
5637+
}
5638+
5639+
# Build self-sign cert/key with password
5640+
interactive_selfsign_PW ()
5641+
{
5642+
unset openssl_nodes
5643+
default='N'
5644+
ia_question_help="
5645+
* Do you want to use a password ?
5646+
5647+
Leave this blank to use the default
5648+
5649+
* Default: $default"
5650+
5651+
ia_question_text='
5652+
Enter (y)es or (n)o:'
5653+
while :
5654+
do
5655+
interactive_question
5656+
ia_answer="${ia_answer:-$default}"
5657+
case "$ia_answer" in
5658+
Y|y|Yes|yes|YES)
5659+
EASYTLS_PASSWORD=1
5660+
break
5661+
;;
5662+
N|n|No|no|NO)
5663+
break
5664+
;;
5665+
*)
5666+
: # Ignore
5667+
;;
5668+
esac
5669+
done
5670+
5671+
easytls_verbose
5672+
#easytls_verbose "Config: $opt_disable_list"
5673+
}
5674+
5675+
# Set commonName and verify cert purpose
55985676
interactive_common_name ()
55995677
{
56005678
unset common_name

0 commit comments

Comments
 (0)