From 02cdeb8663b9819373680efd0d867373258d51f7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 11 Sep 2014 14:08:12 +0100 Subject: [PATCH] Allow re-build of signer chain with specified details (#354). --- ChangeLog | 5 +++ src/wx/config_dialog.cc | 30 ++++++++++++++++ src/wx/make_signer_chain_dialog.cc | 35 +++++++++++++++++++ src/wx/make_signer_chain_dialog.h | 56 ++++++++++++++++++++++++++++++ src/wx/wscript | 1 + 5 files changed, 127 insertions(+) create mode 100644 src/wx/make_signer_chain_dialog.cc create mode 100644 src/wx/make_signer_chain_dialog.h diff --git a/ChangeLog b/ChangeLog index 89185d4e6..da343f6be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-09-11 Carl Hetherington + + * Add option to re-make signing chain with specified organisation, + common names etc. (#354) + 2014-09-10 Carl Hetherington * Version 2.0.8 released. diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index e71b19e37..ada082359 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -49,6 +49,7 @@ #include "isdcf_metadata_dialog.h" #include "preset_colour_conversion_dialog.h" #include "server_dialog.h" +#include "make_signer_chain_dialog.h" using std::vector; using std::string; @@ -604,6 +605,10 @@ public: table->AddGrowableCol (1, 1); overall_sizer->Add (table, 1, wxALL | wxEXPAND, _border); + _remake_certificates = new wxButton (_panel, wxID_ANY, _("Re-make certificates...")); + table->Add (_remake_certificates, 0); + table->AddSpacer (0); + add_label_to_sizer (table, _panel, _("Private key for leaf certificate"), true); { wxSizer* s = new wxBoxSizer (wxHORIZONTAL); @@ -651,6 +656,7 @@ public: _remove_certificate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KeysPage::remove_certificate, this)); _certificates->Bind (wxEVT_COMMAND_LIST_ITEM_SELECTED, boost::bind (&KeysPage::update_sensitivity, this)); _certificates->Bind (wxEVT_COMMAND_LIST_ITEM_DESELECTED, boost::bind (&KeysPage::update_sensitivity, this)); + _remake_certificates->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KeysPage::remake_certificates, this)); _load_signer_private_key->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KeysPage::load_signer_private_key, this)); _load_decryption_certificate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KeysPage::load_decryption_certificate, this)); _load_decryption_private_key->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&KeysPage::load_decryption_private_key, this)); @@ -725,6 +731,29 @@ private: } } + void remake_certificates () + { + MakeSignerChainDialog* d = new MakeSignerChainDialog (_panel); + if (d->ShowModal () == wxID_OK) { + _signer.reset ( + new dcp::Signer ( + openssl_path (), + d->organisation (), + d->organisational_unit (), + d->root_common_name (), + d->intermediate_common_name (), + d->leaf_common_name () + ) + ); + + Config::instance()->set_signer (_signer); + update_certificate_list (); + update_signer_private_key (); + } + + d->Destroy (); + } + void update_sensitivity () { _remove_certificate->Enable (_certificates->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED) != -1); @@ -829,6 +858,7 @@ private: wxListCtrl* _certificates; wxButton* _add_certificate; wxButton* _remove_certificate; + wxButton* _remake_certificates; wxStaticText* _signer_private_key; wxButton* _load_signer_private_key; wxStaticText* _decryption_certificate; diff --git a/src/wx/make_signer_chain_dialog.cc b/src/wx/make_signer_chain_dialog.cc new file mode 100644 index 000000000..8736f2456 --- /dev/null +++ b/src/wx/make_signer_chain_dialog.cc @@ -0,0 +1,35 @@ +/* + Copyright (C) 2014 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "make_signer_chain_dialog.h" + +MakeSignerChainDialog::MakeSignerChainDialog (wxWindow* parent) + : TableDialog (parent, _("Make certificate chain"), 2, true) +{ + add (_("Organisation"), true); + add (_organisation = new wxTextCtrl (this, wxID_ANY)); + add (_("Organisational unit"), true); + add (_organisational_unit = new wxTextCtrl (this, wxID_ANY)); + add (_("Root common name"), true); + add (_root_common_name = new wxTextCtrl (this, wxID_ANY)); + add (_("Intermediate common name"), true); + add (_intermediate_common_name = new wxTextCtrl (this, wxID_ANY)); + add (_("Leaf common name"), true); + add (_leaf_common_name = new wxTextCtrl (this, wxID_ANY)); +} diff --git a/src/wx/make_signer_chain_dialog.h b/src/wx/make_signer_chain_dialog.h new file mode 100644 index 000000000..fc6391a94 --- /dev/null +++ b/src/wx/make_signer_chain_dialog.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2014 Carl Hetherington + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "table_dialog.h" +#include "wx_util.h" + +class MakeSignerChainDialog : public TableDialog +{ +public: + MakeSignerChainDialog (wxWindow* parent); + + std::string organisation () const { + return wx_to_std (_organisation->GetValue ()); + } + + std::string organisational_unit () const { + return wx_to_std (_organisational_unit->GetValue ()); + } + + std::string root_common_name () const { + return wx_to_std (_root_common_name->GetValue ()); + } + + std::string intermediate_common_name () const { + return wx_to_std (_intermediate_common_name->GetValue ()); + } + + std::string leaf_common_name () const { + return wx_to_std (_leaf_common_name->GetValue ()); + } + + +private: + wxTextCtrl* _organisation; + wxTextCtrl* _organisational_unit; + wxTextCtrl* _root_common_name; + wxTextCtrl* _intermediate_common_name; + wxTextCtrl* _leaf_common_name; +}; + diff --git a/src/wx/wscript b/src/wx/wscript index d6e573891..0f39038a5 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -32,6 +32,7 @@ sources = """ job_manager_view.cc job_wrapper.cc kdm_dialog.cc + make_signer_chain_dialog.cc new_film_dialog.cc preset_colour_conversion_dialog.cc properties_dialog.cc -- 2.30.2