-
Notifications
You must be signed in to change notification settings - Fork 15
/
clientCert.ur
45 lines (43 loc) · 1.77 KB
/
clientCert.ur
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
val user =
s <- getenv (blessEnvVar "SSL_CLIENT_S_DN");
case s of
None => return None
| Some s =>
let
val delimiter =
case String.sindex {Haystack = s, Needle = ",emailAddress"} of
Some _ => #","
| None => case String.sindex {Haystack = s, Needle = ",CN"} of
Some _ => #","
| None => #"/"
fun loop s email cname =
case s of
"" =>
(case (email, cname) of
(Some email, Some cname) => Some {Email = email,
CommonName = cname}
| _ => None)
| _ =>
let
val (this, rest) =
case String.split s delimiter of
None => (s, "")
| Some p => p
in
case String.split this #"=" of
None => loop rest email cname
| Some (key, value) =>
let
val email = case key of
"emailAddress" => Some value
| _ => email
val cname = case key of
"CN" => Some value
| _ => cname
in
loop rest email cname
end
end
in
return (loop s None None)
end