From a542ec13a333326c86659779391809b2c5d6d148 Mon Sep 17 00:00:00 2001 From: sunchipnacho <22717474+sunflsks@users.noreply.github.com> Date: Fri, 8 Oct 2021 11:59:49 -0500 Subject: p12 password support --- ldid.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ldid.cpp b/ldid.cpp index c2f7e0a..b664441 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #endif #ifdef __APPLE__ @@ -142,6 +143,10 @@ #define _packed \ __attribute__((packed)) +#ifndef LDID_NOSMIME +std::string password; +#endif + template struct Iterator_ { typedef typename Type_::const_iterator Result; @@ -1787,8 +1792,14 @@ class Stuff { ca_(NULL) { _assert(value_ != NULL); - _assert(PKCS12_parse(value_, "", &key_, &cert_, &ca_) != 0); + if (!PKCS12_verify_mac(value_, "", 0) && password.empty()) { + char passbuf[2048]; + UI_UTIL_read_pw_string(passbuf, 2048, "Enter password: ", 0); + password = passbuf; + } + + _assert(PKCS12_parse(value_, password.c_str(), &key_, &cert_, &ca_) != 0); _assert(key_ != NULL); _assert(cert_ != NULL); @@ -3284,6 +3295,10 @@ int main(int argc, char *argv[]) { flag_M = true; break; + case 'U': + password = argv[argi] + 2; + break; + case 'K': if (argv[argi][2] != '\0') key.open(argv[argi] + 2, O_RDONLY, PROT_READ, MAP_PRIVATE); -- cgit v1.2.3-56-ge451