Skip to content

Commit 1fcbfc6

Browse files
authored
fix(Crypto) Update method to extract friendlyName from certificate (#3787)
* fix(Crypto) Update method to extract friendlyName from certificate
1 parent 49f6def commit 1fcbfc6

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Crypto/src/PKCS12Container.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,12 @@ std::string PKCS12Container::extractFriendlyName(X509* pCert)
128128
std::string friendlyName;
129129
if(pCert)
130130
{
131-
STACK_OF(PKCS12_SAFEBAG)*pBags = 0;
132-
PKCS12_SAFEBAG*pBag = PKCS12_add_cert(&pBags, pCert);
133-
if(pBag)
131+
int length = 0;
132+
char* pBuffer = reinterpret_cast<char*>(X509_alias_get0(pCert, &length));
133+
if (pBuffer)
134134
{
135-
char* pBuffer = PKCS12_get_friendlyname(pBag);
136-
if(pBuffer)
137-
{
138-
friendlyName = pBuffer;
139-
OPENSSL_free(pBuffer);
140-
}
141-
if(pBags) sk_PKCS12_SAFEBAG_pop_free(pBags, PKCS12_SAFEBAG_free);
135+
friendlyName.append(pBuffer, length);
142136
}
143-
else throw OpenSSLException("PKCS12Container::extractFriendlyName()");
144137
}
145138
else throw NullPointerException("PKCS12Container::extractFriendlyName()");
146139

0 commit comments

Comments
 (0)