fix(Crypto) Update method to extract friendlyName from certificate (#3787)

* fix(Crypto) Update method to extract friendlyName from certificate
This commit is contained in:
Damian 2022-09-11 19:28:41 +02:00 committed by GitHub
parent 49f6def959
commit 1fcbfc6094
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,19 +128,12 @@ std::string PKCS12Container::extractFriendlyName(X509* pCert)
std::string friendlyName; std::string friendlyName;
if(pCert) if(pCert)
{ {
STACK_OF(PKCS12_SAFEBAG)*pBags = 0; int length = 0;
PKCS12_SAFEBAG*pBag = PKCS12_add_cert(&pBags, pCert); char* pBuffer = reinterpret_cast<char*>(X509_alias_get0(pCert, &length));
if(pBag) if (pBuffer)
{ {
char* pBuffer = PKCS12_get_friendlyname(pBag); friendlyName.append(pBuffer, length);
if(pBuffer)
{
friendlyName = pBuffer;
OPENSSL_free(pBuffer);
}
if(pBags) sk_PKCS12_SAFEBAG_pop_free(pBags, PKCS12_SAFEBAG_free);
} }
else throw OpenSSLException("PKCS12Container::extractFriendlyName()");
} }
else throw NullPointerException("PKCS12Container::extractFriendlyName()"); else throw NullPointerException("PKCS12Container::extractFriendlyName()");