-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverCA_V3.sh
69 lines (50 loc) · 1.87 KB
/
serverCA_V3.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#===============================================================================
# Ergis Kocumi v.3.0 of the script
# FILE: serverCA_V3.sh
#
# USAGE: ./serverCA_V3.sh
# This script is used for creating:
# 1. the key for the server
# 2. The CSR for the server with the key of 1.
# 3. Creating the X509 DIGITAL CERTIFICATE for the server signed by the CAkey
# that is created with the script "genSSL_V3.sh"
#===============================================================================
### function declarations ###
#function to print the info for evere step like "DEBUG"
info()
{
printf '\n%s\t%s\t' "INFO" "$@"
}
#function for printing the error if it happens
fatal()
{
printf '\n%s\t%s\n' "ERROR" "$@"
exit 1
}
genServer_Certs()
{
#STEP 1: creating che key for the server
info "Generate Private Key for the Server"
#COMAND:
openssl genrsa -out server.key.pem 4096 2>/dev/null && echo -n "[DONE]" || fatal "Unable to Generate Private Key for the Server"
#STEP 2: generate the CSR for server with the key at step 1
info "Generate CSR for server certificate"
#COMAND:
openssl req -new -key server.key.pem -out server.csr || fatal "unable to generate CSR for the server"
## MI SI BLOCCA QUI e mi da il FATAL con l'errore
#STEP 3: verify the csr
info "Verify the CSR created before"
#COMAND:
openssl req -in server.csr -noout -text
#STEP 6: creating the CERTIFICATE
info "Generate a digital certificate x509 for the client/server"
#COMAND:
openssl x509 -req -in server.csr -extfile v3.ext -CA CAcert.pem -CAkey CAkey.pem -CAcreateserial -out srv_mydomain_com.crt -days 500 -sha256
#STEP 7: verify the certificate created before
info "verify the certificate created before"
#COMAND:
openssl x509 -in srv_mydomain_com.crt -text -noout
}
## MAIN START ##
genServer_Certs