gnutls_x509_crt_list_import does not support multiple DER certificates (Georg Sauthoff).
This commit is contained in:
parent
0537a5eb8e
commit
3442caf607
@ -292,27 +292,26 @@ ref <security::cert::certificateChain> TLSSocket::getPeerCertificates() const
|
|||||||
// Try X.509
|
// Try X.509
|
||||||
gnutls_x509_crt* x509Certs = new gnutls_x509_crt[certCount];
|
gnutls_x509_crt* x509Certs = new gnutls_x509_crt[certCount];
|
||||||
|
|
||||||
unsigned int count = certCount;
|
for (unsigned int i = 0; i < certCount; ++i)
|
||||||
|
|
||||||
int res = gnutls_x509_crt_list_import
|
|
||||||
(x509Certs, &count, rawData, GNUTLS_X509_FMT_PEM, 0);
|
|
||||||
|
|
||||||
if (res <= 0)
|
|
||||||
{
|
{
|
||||||
count = certCount;
|
gnutls_x509_crt_init(x509Certs + i);
|
||||||
|
|
||||||
res = gnutls_x509_crt_list_import
|
int res = gnutls_x509_crt_import(x509Certs[i], rawData + i,
|
||||||
(x509Certs, &count, rawData, GNUTLS_X509_FMT_DER, 0);
|
GNUTLS_X509_FMT_DER);
|
||||||
|
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
// XXX more fine-grained error reporting?
|
||||||
|
delete [] x509Certs;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res >= 1)
|
|
||||||
{
|
{
|
||||||
std::vector <ref <security::cert::certificate> > certs;
|
std::vector <ref <security::cert::certificate> > certs;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
|
|
||||||
count = static_cast <unsigned int>(res);
|
for (unsigned int i = 0 ; i < certCount ; ++i)
|
||||||
|
|
||||||
for (unsigned int i = 0 ; i < count ; ++i)
|
|
||||||
{
|
{
|
||||||
size_t dataSize = 0;
|
size_t dataSize = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user