X-Git-Url: https://git.distorted.org.uk/~mdw/ca/blobdiff_plain/71669a0ab999914152a97ee81edc837f8c1a3277..2244ef69ba751fb58c4655f2cd036a675ce96879:/lib/func.tcl diff --git a/lib/func.tcl b/lib/func.tcl index a3b58dc..3dd35c3 100644 --- a/lib/func.tcl +++ b/lib/func.tcl @@ -425,7 +425,7 @@ proc sync-profiles {} { UPDATE profile SET extensions = $d(extensions), issue_time = $d(issue-time), - start_skew = $(start-skew), + start_skew = $d(start-skew), expire_interval = $d(expire-interval), tombstone = 0 WHERE label = $p; @@ -454,13 +454,21 @@ proc req-key-hash {file} { openssl dgst -sha256 -hex] end] } +proc hack-openssl-dn {out} { + ## Convert OpenSSL's hopeless output into a DN. + + if {[regexp {^subject=\s*(/.*)$} $out -> dn]} { return $dn } + if {[regexp {^subject=(.*)$} $out -> t]} { + set t [regsub {^(\w+) = } $t {/\1=}] + set t [regsub -all {, (\w+) = } $t {/\1=}] + return $t + } +} + proc req-dn {file} { ## Return the distinguished name from the certificate request in FILE. - regexp {^subject=\s*(/.*)$} \ - [exec openssl req -in $file -noout -subject] \ - -> dn - return $dn + return [hack-openssl-dn [exec openssl req -in $file -noout -subject]] } proc cert-key-hash {file} { @@ -475,10 +483,7 @@ proc cert-key-hash {file} { proc cert-dn {file} { ## Return the distinguished name from the certificate in FILE. - regexp {^subject=\s*(/.*)$} \ - [exec openssl x509 -in $file -noout -subject] \ - -> dn - return $dn + return [hack-openssl-dn [exec openssl x509 -in $file -noout -subject]] } proc cert-seq {file} {