diff --git a/DesktopEditor/xmlsec/src/include/XmlCertificate.h b/DesktopEditor/xmlsec/src/include/XmlCertificate.h index 52ea64d5e0..24bcb0a323 100644 --- a/DesktopEditor/xmlsec/src/include/XmlCertificate.h +++ b/DesktopEditor/xmlsec/src/include/XmlCertificate.h @@ -8,6 +8,7 @@ #define OOXML_HASH_ALG_SHA1 0 #define OOXML_HASH_ALG_INVALID 1 +class ICertificate; class Q_DECL_EXPORT ICertificateSelectDialogOpenSsl { public: @@ -26,7 +27,7 @@ public: virtual std::wstring GetKeyPassword() = 0; virtual bool ShowSelectDialog() = 0; - virtual int ShowCertificate() = 0; + virtual int ShowCertificate(ICertificate* pCert) = 0; }; class Q_DECL_EXPORT CCertificateInfo diff --git a/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h b/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h index d3dadfd7d4..ce8d8503cb 100644 --- a/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h +++ b/DesktopEditor/xmlsec/src/src/XmlSigner_openssl.h @@ -281,14 +281,41 @@ public: public: virtual bool ShowSelectDialog() { - if (m_pDialog) - return m_pDialog->ShowSelectDialog(); - return false; + if (!m_pDialog) + return false; + + bool bResult = m_pDialog->ShowSelectDialog(); + + std::wstring sKeyPath = m_pDialog->GetKeyPath(); + std::wstring sKeyPasswordW = m_pDialog->GetKeyPassword(); + std::string sKeyPassword = U_TO_UTF8(sKeyPasswordW); + + std::wstring sCertPath = m_pDialog->GetCertificatePath(); + std::wstring sCertPasswordW = m_pDialog->GetCertificatePassword(); + std::string sCertPassword = U_TO_UTF8(sCertPasswordW); + + if (sCertPath.empty()) + { + sCertPath = sKeyPath; + sCertPassword = sKeyPassword; + } + + int nErr = LoadKey(sKeyPath, sKeyPassword, &m_key); + + if (nErr != OPEN_SSL_WARNING_OK && nErr != OPEN_SSL_WARNING_ALL_OK) + return false; + + nErr = LoadCert(sCertPath, sCertPassword, &m_cert); + + if (nErr != OPEN_SSL_WARNING_OK && nErr != OPEN_SSL_WARNING_ALL_OK) + return false; + + return true; } virtual int ShowCertificate() { if (m_pDialog) - return m_pDialog->ShowCertificate(); + return m_pDialog->ShowCertificate(this); return 1; }