Skip to content

Commit b245449

Browse files
committed
gencert: name the pem parsers
Helpful for debugging pem-parsing issues Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent c264219 commit b245449

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ocaml/gencert/pem.ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,31 @@ let footer = function
4343
| OTHER ->
4444
"-----END PRIVATE KEY-----"
4545

46-
let key_header = string "-----BEGIN" *> kind <* string "PRIVATE KEY-----"
46+
let key_header =
47+
string "-----BEGIN" *> kind <* string "PRIVATE KEY-----" <?> "key_header"
4748

48-
let key_footer k = string (footer k)
49+
let key_footer k = string (footer k) <?> "key_footer"
4950

50-
let cert_header = string "-----BEGIN CERTIFICATE-----"
51+
let cert_header = string "-----BEGIN CERTIFICATE-----" <?> "cert_header"
5152

52-
let cert_footer = string "-----END CERTIFICATE-----"
53+
let cert_footer = string "-----END CERTIFICATE-----" <?> "cert_footer"
5354

5455
let key =
5556
key_header >>= fun kind ->
5657
data >>= fun body ->
5758
key_footer kind *> return (String.concat "" [header kind; body; footer kind])
59+
<?> "key"
5860

5961
let cert =
6062
cert_header >>= fun hd ->
6163
data >>= fun body ->
62-
cert_footer >>= fun tl -> return (String.concat "" [hd; body; tl])
64+
cert_footer >>= fun tl -> return (String.concat "" [hd; body; tl]) <?> "cert"
6365

6466
let pem =
6567
many end_of_line *> key >>= fun private_key ->
6668
many end_of_line *> cert >>= fun host_cert ->
6769
many end_of_line *> many cert >>= fun other_certs ->
68-
many end_of_line *> return {private_key; host_cert; other_certs}
70+
many end_of_line *> return {private_key; host_cert; other_certs} <?> "pem"
6971

7072
let defer f = Fun.protect ~finally:f
7173

0 commit comments

Comments
 (0)