+
+ void load_certificate ()
+ {
+ auto dialog = new FileDialog(this, _("Trusted Device certificate"), wxEmptyString, wxFD_DEFAULT_STYLE, "SelectCertificatePath");
+ ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ if (!dialog->show()) {
+ return;
+ }
+
+ try {
+ _certificate = dcp::Certificate(dcp::file_to_string(dialog->paths()[0]));
+ _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;