Force .pem extension when saving certificates.
authorCarl Hetherington <cth@carlh.net>
Sat, 6 Feb 2021 19:39:33 +0000 (20:39 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 6 Feb 2021 19:45:22 +0000 (20:45 +0100)
src/wx/config_dialog.cc

index 9e630195fa740a91ace897d03f72838cdd04d86d..3f270afbc988b0af937e15d263751ef5475bfb23 100644 (file)
@@ -459,7 +459,10 @@ CertificateChainEditor::export_certificate ()
 
        if (d->ShowModal () == wxID_OK) {
                boost::filesystem::path path (wx_to_std(d->GetPath()));
-               FILE* f = fopen_boost (path, "w");
+               if (path.extension() != ".pem") {
+                       path += ".pem";
+               }
+               auto f = fopen_boost (path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }
@@ -481,7 +484,10 @@ CertificateChainEditor::export_chain ()
 
        if (d->ShowModal () == wxID_OK) {
                boost::filesystem::path path (wx_to_std(d->GetPath()));
-               FILE* f = fopen_boost (path, "w");
+               if (path.extension() != ".pem") {
+                       path += ".pem";
+               }
+               auto f = fopen_boost (path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }
@@ -655,7 +661,10 @@ CertificateChainEditor::export_private_key ()
 
        if (d->ShowModal () == wxID_OK) {
                boost::filesystem::path path (wx_to_std(d->GetPath()));
-               FILE* f = fopen_boost (path, "w");
+               if (path.extension() != ".pem") {
+                       path += ".pem";
+               }
+               auto f = fopen_boost (path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }
@@ -839,7 +848,10 @@ KeysPage::export_decryption_certificate ()
 
        if (d->ShowModal () == wxID_OK) {
                boost::filesystem::path path (wx_to_std(d->GetPath()));
-               FILE* f = fopen_boost (path, "w");
+               if (path.extension() != ".pem") {
+                       path += ".pem";
+               }
+               auto f = fopen_boost (path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }