void remake_certificates ()
{
- MakeSignerChainDialog* d = new MakeSignerChainDialog (_panel);
+ dcp::CertificateChain chain = Config::instance()->signer()->certificates ();
+
+ string intermediate_common_name;
+ if (chain.root_to_leaf().size() >= 3) {
+ dcp::CertificateChain::List all = chain.root_to_leaf ();
+ dcp::CertificateChain::List::iterator i = all.begin ();
+ ++i;
+ intermediate_common_name = i->subject_common_name ();
+ }
+
+ MakeSignerChainDialog* d = new MakeSignerChainDialog (
+ _panel,
+ chain.root().subject_organization_name (),
+ chain.root().subject_organizational_unit_name (),
+ chain.root().subject_common_name (),
+ intermediate_common_name,
+ chain.leaf().subject_common_name ()
+ );
+
if (d->ShowModal () == wxID_OK) {
_signer.reset (
new dcp::Signer (
*/
#include "make_signer_chain_dialog.h"
+#include <boost/algorithm/string.hpp>
-MakeSignerChainDialog::MakeSignerChainDialog (wxWindow* parent)
+using std::string;
+
+MakeSignerChainDialog::MakeSignerChainDialog (
+ wxWindow* parent,
+ string organisation,
+ string organisational_unit_name,
+ string root_common_name,
+ string intermediate_common_name,
+ string leaf_common_name
+ )
: TableDialog (parent, _("Make certificate chain"), 2, true)
{
wxTextValidator validator (wxFILTER_EXCLUDE_CHAR_LIST);
validator.SetCharExcludes (wxT ("/"));
+ if (boost::algorithm::starts_with (root_common_name, ".")) {
+ root_common_name = root_common_name.substr (1);
+ }
+
+ if (boost::algorithm::starts_with (intermediate_common_name, ".")) {
+ intermediate_common_name = intermediate_common_name.substr (1);
+ }
+
+ if (boost::algorithm::starts_with (leaf_common_name, "CS.")) {
+ leaf_common_name = leaf_common_name.substr (3);
+ }
+
add (_("Organisation"), true);
- add (_organisation = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator));
+ add (_organisation = new wxTextCtrl (this, wxID_ANY, std_to_wx (organisation), wxDefaultPosition, wxDefaultSize, 0, validator));
add (_("Organisational unit"), true);
- add (_organisational_unit = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator));
+ add (_organisational_unit = new wxTextCtrl (this, wxID_ANY, std_to_wx (organisational_unit_name), wxDefaultPosition, wxDefaultSize, 0, validator));
add (_("Root common name"), true);
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
s->Add (new wxStaticText (this, wxID_ANY, wxT (".")), 0, wxALIGN_CENTER_VERTICAL);
s->Add (_root_common_name = new wxTextCtrl (
- this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
+ this, wxID_ANY, std_to_wx (root_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
);
add (s);
}
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
s->Add (new wxStaticText (this, wxID_ANY, wxT (".")), 0, wxALIGN_CENTER_VERTICAL);
s->Add (_intermediate_common_name = new wxTextCtrl (
- this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
+ this, wxID_ANY, std_to_wx (intermediate_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
);
add (s);
}
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
s->Add (new wxStaticText (this, wxID_ANY, wxT ("CS.")), 0, wxALIGN_CENTER_VERTICAL);
s->Add (_leaf_common_name = new wxTextCtrl (
- this, wxID_ANY, wxT (""), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
+ this, wxID_ANY, std_to_wx (leaf_common_name), wxDefaultPosition, wxDefaultSize, 0, validator), 1, wxALIGN_CENTER_VERTICAL
);
add (s);
}