summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-28 23:10:45 +0100
committerCarl Hetherington <cth@carlh.net>2025-10-28 23:13:32 +0100
commite134af0bdfcd5197ea236f835dece0521ebf6b2e (patch)
tree2b33de7f034bcf669a568d84bf97a646041ef1b2 /src/lib
parent27b1be571e188b0f5f2d006f5d7cf1349695a9fa (diff)
Fix decryption import code to work with PKCS1 and PKCS8 formats.
PKCS1 uses BEGIN RSA PRIVATE KEY but PKCS8 has only BEGIN PRIVATE KEY
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/export_decryption_settings.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/export_decryption_settings.cc b/src/lib/export_decryption_settings.cc
index 1ba791251..13c6bda28 100644
--- a/src/lib/export_decryption_settings.cc
+++ b/src/lib/export_decryption_settings.cc
@@ -65,10 +65,10 @@ import_decryption_chain_and_key(boost::filesystem::path const& path)
}
current += buffer;
- if (strncmp(buffer, "-----END CERTIFICATE-----", 25) == 0) {
+ if (current.find("-----END CERTIFICATE-----") != string::npos) {
new_chain->add(dcp::Certificate(current));
current = "";
- } else if (strncmp(buffer, "-----END RSA PRIVATE KEY-----", 29) == 0) {
+ } else if (current.find("-----END") != string::npos && current.find("PRIVATE KEY-----", 29) != string::npos) {
new_chain->set_key(current);
current = "";
}