Comparison

prosodyctl @ 5546:edc97af48d19

prosodyctl: Ask about the distinguished name in a in a consistent order
author Kim Alvefur <zash@zash.se>
date Mon, 29 Apr 2013 14:00:44 +0200
parent 5545:d22416f8a836
child 5547:f306daf2bf6d
comparison
equal deleted inserted replaced
5545:d22416f8a836 5546:edc97af48d19
660 end 660 end
661 local conf = openssl.config.new(); 661 local conf = openssl.config.new();
662 conf:from_prosody(hosts, config, arg); 662 conf:from_prosody(hosts, config, arg);
663 show_message("Please provide details to include in the certificate config file."); 663 show_message("Please provide details to include in the certificate config file.");
664 show_message("Leave the field empty to use the default value or '.' to exclude the field.") 664 show_message("Leave the field empty to use the default value or '.' to exclude the field.")
665 for k, v in pairs(conf.distinguished_name) do 665 for i, k in ipairs(openssl._DN_order) do
666 local nv; 666 local v = conf.distinguished_name[k];
667 if k == "commonName" then 667 if v then
668 v = arg[1] 668 local nv;
669 elseif k == "emailAddress" then 669 if k == "commonName" then
670 v = "xmpp@" .. arg[1]; 670 v = arg[1]
671 end 671 elseif k == "emailAddress" then
672 nv = show_prompt(("%s (%s):"):format(k, nv or v)); 672 v = "xmpp@" .. arg[1];
673 nv = (not nv or nv == "") and v or nv; 673 end
674 if nv:find"[\192-\252][\128-\191]+" then 674 nv = show_prompt(("%s (%s):"):format(k, nv or v));
675 conf.req.string_mask = "utf8only" 675 nv = (not nv or nv == "") and v or nv;
676 end 676 if nv:find"[\192-\252][\128-\191]+" then
677 conf.distinguished_name[k] = nv ~= "." and nv or nil; 677 conf.req.string_mask = "utf8only"
678 end
679 conf.distinguished_name[k] = nv ~= "." and nv or nil;
680 end
678 end 681 end
679 local conf_file = io.open(conf_filename, "w"); 682 local conf_file = io.open(conf_filename, "w");
680 conf_file:write(conf:serialize()); 683 conf_file:write(conf:serialize());
681 conf_file:close(); 684 conf_file:close();
682 print(""); 685 print("");