Skip to content

Commit

Permalink
Code style fix
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
josesimoes committed Aug 13, 2021
1 parent 33c5acc commit 5382143
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions src/PAL/COM/sockets/ssl/mbedTLS/ssl_parse_certificate_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

#include "mbedtls.h"

void SSL_GetCertDateTime_internal(
DATE_TIME_INFO * dt,
mbedtls_x509_time * mt )
void SSL_GetCertDateTime_internal(DATE_TIME_INFO *dt, mbedtls_x509_time *mt)
{
dt->year = mt->year;
dt->month = mt->mon;
Expand All @@ -21,51 +19,34 @@ void SSL_GetCertDateTime_internal(
dt->tzOffset = 0;
}

bool ssl_parse_certificate_internal(
void * certificate,
size_t size,
void* pwd,
void* x509CertData)
bool ssl_parse_certificate_internal(void *certificate, size_t size, void *pwd, void *x509CertData)
{
(void)pwd;

int ret;
X509CertData* x509 = (X509CertData*)x509CertData;
X509CertData *x509 = (X509CertData *)x509CertData;

mbedtls_x509_crt cacert;
mbedtls_x509_crt_init(&cacert);

/////////////////////////////////////////////////////////////////////////////////////////////////
// developer notes: //
// this call parses certificates in both string and binary formats //
// when the formart is a string it has to include the terminator otherwise the parse will fail //
/////////////////////////////////////////////////////////////////////////////////////////////////
ret = mbedtls_x509_crt_parse(
&cacert,
(const unsigned char *)certificate,
size);
if(ret < 0)
ret = mbedtls_x509_crt_parse(&cacert, (const unsigned char *)certificate, size);
if (ret < 0)
{
return false;
}

mbedtls_x509_dn_gets(
x509->Issuer,
sizeof(x509->Issuer)-1,
&cacert.issuer );

mbedtls_x509_dn_gets(
x509->Subject,
sizeof(x509->Subject)-1,
&cacert.subject );
mbedtls_x509_dn_gets(x509->Issuer, sizeof(x509->Issuer) - 1, &cacert.issuer);

mbedtls_x509_dn_gets(x509->Subject, sizeof(x509->Subject) - 1, &cacert.subject);

SSL_GetCertDateTime_internal(
&x509->EffectiveDate,
&cacert.valid_from );
SSL_GetCertDateTime_internal(&x509->EffectiveDate, &cacert.valid_from);

SSL_GetCertDateTime_internal(
&x509->ExpirationDate,
&cacert.valid_to );
SSL_GetCertDateTime_internal(&x509->ExpirationDate, &cacert.valid_to);

return true;
}

0 comments on commit 5382143

Please sign in to comment.