+ void export_private_key ()
+ {
+ optional<string> key = _chain->key ();
+ if (!key) {
+ return;
+ }
+
+ wxFileDialog* d = new wxFileDialog (
+ this, _("Select Key File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"),
+ wxFD_SAVE | wxFD_OVERWRITE_PROMPT
+ );
+
+ if (d->ShowModal () == wxID_OK) {
+ FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "w");
+ if (!f) {
+ throw OpenFileError (wx_to_std (d->GetPath ()));
+ }
+
+ string const s = _chain->key().get ();
+ fwrite (s.c_str(), 1, s.length(), f);
+ fclose (f);
+ }
+ d->Destroy ();
+ }
+