5
5
// File name is placed in ./tmp with a random name. It lingers unless
6
6
// removed manually.
7
7
//
8
- function CA_create_cnf ($ country ='' ,$ province ='' ,$ locality ='' ,$ organization ='' ,$ unit ='' ,$ common_name ='' ,$ email ='' ,$ keysize =4096 ,$ dns_names ='' ,$ ip_addr ='' ) {
8
+ function CA_create_cnf ($ country ='' ,$ province ='' ,$ locality ='' ,$ organization ='' ,$ unit ='' ,$ common_name ='' ,$ email ='' ,$ keysize =4096 ,$ dns_names ='' ,$ ip_addr ='' , $ serial = '' ) {
9
9
global $ config , $ PHPki_user ;
10
10
11
11
$ issuer = $ PHPki_user ;
@@ -18,20 +18,23 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
18
18
$ dns_n =explode ("\n" , $ dns_names );
19
19
$ count_dns = $ count_dns + 1 ;
20
20
$ alt_names .= "DNS. $ count_dns = $ common_name \n" ;
21
-
22
21
foreach ($ dns_n as $ value ) {
22
+ if (! $ value == '' ) {
23
23
$ count_dns = $ count_dns + 1 ;
24
24
$ alt_names .= "DNS. $ count_dns = " .trim ($ value )."\n" ;
25
+ }
25
26
}
26
27
}
27
28
28
29
if (! $ ip_addr == '' ) {
29
30
$ ip_ar =explode ("\n" , $ ip_addr );
30
31
foreach ($ ip_ar as $ value ) {
32
+ if (! $ value == '' ) {
31
33
$ count_dns = $ count_dns + 1 ;
32
34
$ count_ip = $ count_ip + 1 ;
33
35
$ alt_names .= "DNS. $ count_dns = " .trim ($ value )."\n" ;
34
36
$ alt_names .= "IP. $ count_ip = " .trim ($ value )."\n" ;
37
+ }
35
38
}
36
39
}
37
40
@@ -44,7 +47,7 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
44
47
$ cnf_contents = "
45
48
HOME = $ config [home_dir]
46
49
RANDFILE = $ config [random]
47
- dir = $ config [ca_dir]
50
+ dir = $ config [ca_dir]
48
51
certs = $ config [cert_dir]
49
52
crl_dir = $ config [crl_dir]
50
53
database = $ config [index]
@@ -135,7 +138,7 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
135
138
subjectAltName = email:copy
136
139
crlDistributionPoints = URI: $ config [base_url]index.php?stage=dl_crl
137
140
nsComment = \"PHPki/OpenSSL Generated Root Certificate \"
138
- #nsCaRevocationUrl = $ config [base_url]ns_revoke_query.php? $ config [ serial]
141
+ #nsCaRevocationUrl = $ config [base_url]ns_revoke_query.php? $ serial
139
142
nsCaPolicyUrl = $ config [base_url]policy.html
140
143
141
144
[ email_ext ]
@@ -150,7 +153,7 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
150
153
crlDistributionPoints = URI: $ config [base_url]index.php?stage=dl_crl
151
154
nsComment = \"PHPki/OpenSSL Generated Personal Certificate \"
152
155
nsBaseUrl = $ config [base_url]
153
- nsRevocationUrl = $ config [base_url]ns_revoke_query.php? $ config [ serial]
156
+ nsRevocationUrl = $ config [base_url]ns_revoke_query.php? $ serial
154
157
nsCaPolicyUrl = $ config [base_url]policy.html
155
158
156
159
[ email_signing_ext ]
@@ -165,7 +168,7 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
165
168
crlDistributionPoints = URI: $ config [base_url]index.php?stage=dl_crl
166
169
nsComment = \"PHPki/OpenSSL Generated Personal Certificate \"
167
170
nsBaseUrl = $ config [base_url]
168
- nsRevocationUrl = $ config [base_url]ns_revoke_query.php? $ config [ serial]
171
+ nsRevocationUrl = $ config [base_url]ns_revoke_query.php? $ serial
169
172
nsCaPolicyUrl = $ config [base_url]policy.html
170
173
171
174
[ server_ext ]
@@ -180,7 +183,7 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
180
183
crlDistributionPoints = URI: $ config [base_url]index.php?stage=dl_crl
181
184
nsComment = \"PHPki/OpenSSL Generated Server Certificate \"
182
185
nsBaseUrl = $ config [base_url]
183
- nsRevocationUrl = $ config [base_url]ns_revoke_query.php? $ config [ serial]
186
+ nsRevocationUrl = $ config [base_url]ns_revoke_query.php? $ serial
184
187
nsCaPolicyUrl = $ config [base_url]policy.html
185
188
186
189
[ time_stamping_ext ]
@@ -194,7 +197,7 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
194
197
crlDistributionPoints = URI: $ config [base_url]index.php?stage=dl_crl
195
198
nsComment = \"PHPki/OpenSSL Generated Time Stamping Certificate \"
196
199
nsBaseUrl = $ config [base_url]
197
- nsRevocationUrl = $ config [base_url]ns_revoke_query.php? $ config [ serial]
200
+ nsRevocationUrl = $ config [base_url]ns_revoke_query.php? $ serial
198
201
199
202
[ vpn_client_ext ]
200
203
basicConstraints = critical, CA:false
@@ -519,11 +522,11 @@ function CA_create_cert($cert_type='email',$country,$province,$locality,$organiz
519
522
520
523
$ expiry_days = round ($ expiry * 365.25 , 0 );
521
524
522
- $ cnf_file = CA_create_cnf ($ country ,$ province ,$ locality ,$ organization ,$ unit ,$ common_name ,$ email ,$ keysize ,$ dns_names ,$ ip_addr );
525
+ $ cnf_file = CA_create_cnf ($ country ,$ province ,$ locality ,$ organization ,$ unit ,$ common_name ,$ email ,$ keysize ,$ dns_names ,$ ip_addr, $ serial );
523
526
524
527
# Escape certain dangerous characters in user input
525
528
$ email = escshellcmd ($ email );
526
- $ _passwd = escshellarg ($ passwd );
529
+ $ _passwd = escshellarg ($ passwd );
527
530
$ friendly_name = escshellarg ($ common_name );
528
531
$ extensions = escshellarg ($ cert_type .'_ext ' );
529
532
0 commit comments