+void
+CertificateChainEditor::export_chain ()
+{
+ wxFileDialog* d = new wxFileDialog (
+ this, _("Select Chain File"), wxEmptyString, wxEmptyString, wxT("PEM files (*.pem)|*.pem"),
+ wxFD_SAVE | wxFD_OVERWRITE_PROMPT
+ );
+
+ if (d->ShowModal () == wxID_OK) {
+ boost::filesystem::path path (wx_to_std(d->GetPath()));
+ FILE* f = fopen_boost (path, "w");
+ if (!f) {
+ throw OpenFileError (path, errno, false);
+ }
+
+ string const s = _get()->chain();
+ checked_fwrite (s.c_str(), s.length(), f, path);
+ fclose (f);
+ }
+
+ d->Destroy ();
+}
+