Comparison

util/openssl.lua @ 5544:d911d9fb3929

util.openssl: Write the distinguished_name part of the config in a consistent order
author Kim Alvefur <zash@zash.se>
date Mon, 29 Apr 2013 13:30:59 +0200
parent 5379:27de7cc94111
child 6902:d2d7ad2563f9
comparison
equal deleted inserted replaced
5542:329ebdfb39a2 5544:d911d9fb3929
21 req_extensions = "v3_extensions", 21 req_extensions = "v3_extensions",
22 x509_extensions = "v3_extensions", 22 x509_extensions = "v3_extensions",
23 prompt = "no", 23 prompt = "no",
24 }, 24 },
25 distinguished_name = { 25 distinguished_name = {
26 commonName = "example.com",
27 countryName = "GB", 26 countryName = "GB",
27 -- stateOrProvinceName = "",
28 localityName = "The Internet", 28 localityName = "The Internet",
29 organizationName = "Your Organisation", 29 organizationName = "Your Organisation",
30 organizationalUnitName = "XMPP Department", 30 organizationalUnitName = "XMPP Department",
31 commonName = "example.com",
31 emailAddress = "xmpp@example.com", 32 emailAddress = "xmpp@example.com",
32 }, 33 },
33 v3_extensions = { 34 v3_extensions = {
34 basicConstraints = "CA:FALSE", 35 basicConstraints = "CA:FALSE",
35 keyUsage = "digitalSignature,keyEncipherment", 36 keyUsage = "digitalSignature,keyEncipherment",
41 otherName = {}, 42 otherName = {},
42 }, 43 },
43 }, ssl_config_mt); 44 }, ssl_config_mt);
44 end 45 end
45 46
47 local DN_order = {
48 "countryName";
49 "stateOrProvinceName";
50 "localityName";
51 "streetAddress";
52 "organizationName";
53 "organizationalUnitName";
54 "commonName";
55 "emailAddress";
56 }
57 _M._DN_order = DN_order;
46 function ssl_config:serialize() 58 function ssl_config:serialize()
47 local s = ""; 59 local s = "";
48 for k, t in pairs(self) do 60 for k, t in pairs(self) do
49 s = s .. ("[%s]\n"):format(k); 61 s = s .. ("[%s]\n"):format(k);
50 if k == "subject_alternative_name" then 62 if k == "subject_alternative_name" then
51 for san, n in pairs(t) do 63 for san, n in pairs(t) do
52 for i = 1,#n do 64 for i = 1,#n do
53 s = s .. s_format("%s.%d = %s\n", san, i -1, n[i]); 65 s = s .. s_format("%s.%d = %s\n", san, i -1, n[i]);
66 end
67 end
68 elseif k == "distinguished_name" then
69 for i=1,#DN_order do
70 local k = DN_order[i]
71 local v = t[k];
72 if v then
73 s = s .. ("%s = %s\n"):format(k, v);
54 end 74 end
55 end 75 end
56 else 76 else
57 for k, v in pairs(t) do 77 for k, v in pairs(t) do
58 s = s .. ("%s = %s\n"):format(k, v); 78 s = s .. ("%s = %s\n"):format(k, v);