Hanno Böck commited on 2022-07-03 09:47:02
Zeige 1 geänderte Dateien mit 6 Einfügungen und 9 Löschungen.
... | ... |
@@ -210,20 +210,14 @@ function validate_certificate($cert, $key) |
210 | 210 |
function parse_cert_details($cert) |
211 | 211 |
{ |
212 | 212 |
$certdata = openssl_x509_parse($cert, true); |
213 |
- /* |
|
214 |
-name => /CN=*.bwurst.org |
|
215 |
-validFrom_time_t => 1204118790 |
|
216 |
-validTo_time_t => 1267190790 |
|
217 |
- |
|
218 |
- |
|
219 |
- */ |
|
220 | 213 |
DEBUG($certdata); |
221 |
- DEBUG("SAN: ".$certdata['extensions']['subjectAltName']); |
|
222 |
- //return array('subject' => $certdata['name'], 'cn' => $certdata['subject']['CN'], 'valid_from' => date('Y-m-d', $certdata['validFrom_time_t']), 'valid_until' => date('Y-m-d', $certdata['validTo_time_t'])); |
|
214 |
+ |
|
223 | 215 |
$issuer = $certdata['issuer']['CN']; |
224 | 216 |
if (isset($certdata['issuer']['O'])) { |
225 | 217 |
$issuer = $certdata['issuer']['O']; |
226 | 218 |
} |
219 |
+ if (isset($certdata['extensions']['subjectAltName'])) { |
|
220 |
+ DEBUG("SAN: ".$certdata['extensions']['subjectAltName']); |
|
227 | 221 |
$san = []; |
228 | 222 |
$raw_san = explode(', ', $certdata['extensions']['subjectAltName']); |
229 | 223 |
foreach ($raw_san as $name) { |
... | ... |
@@ -234,6 +228,9 @@ validTo_time_t => 1267190790 |
234 | 228 |
$san[] = str_replace('DNS:', '', $name); |
235 | 229 |
} |
236 | 230 |
$san = implode("\n", $san); |
231 |
+ } else { |
|
232 |
+ $san = "\n"; |
|
233 |
+ } |
|
237 | 234 |
DEBUG("SAN: <pre>".$san."</pre>"); |
238 | 235 |
return ['subject' => $certdata['subject']['CN'].' / '.$issuer, 'cn' => $certdata['subject']['CN'], 'valid_from' => date('Y-m-d', $certdata['validFrom_time_t']), 'valid_until' => date('Y-m-d', $certdata['validTo_time_t']), 'issuer' => $certdata['issuer']['CN'], 'san' => $san]; |
239 | 236 |
} |
240 | 237 |