+
+ void load_certificate ()
+ {
+ auto d = new wxFileDialog (this, _("Trusted Device certificate"));
+ if (d->ShowModal() == wxID_OK) {
+ try {
+ _certificate = dcp::Certificate(dcp::file_to_string(wx_to_std(d->GetPath())));
+ _thumbprint->SetValue (std_to_wx(_certificate->thumbprint()));
+ } catch (dcp::MiscError& e) {
+ error_dialog(this, wxString::Format(_("Could not load certificate (%s)"), std_to_wx(e.what())));
+ }
+ }
+ }
+
+ void set (TrustedDevice t)
+ {
+ _certificate = t.certificate ();
+ _thumbprint->SetValue (std_to_wx(t.thumbprint()));
+ }
+
+ optional<TrustedDevice> get ()
+ {
+ auto const t = wx_to_std (_thumbprint->GetValue());
+ if (_certificate && _certificate->thumbprint() == t) {
+ return TrustedDevice (*_certificate);
+ } else if (t.length() == 28) {
+ return TrustedDevice (t);
+ }
+
+ return {};
+ }
+
+private:
+ wxTextCtrl* _thumbprint;
+ wxButton* _file;
+ boost::optional<dcp::Certificate> _certificate;