mirror of https://github.com/FreeRDP/FreeRDP
[crypto,cert] add getter for notBefore and notAfter
Add getters for ceritificate dates notBefore and notAfter. Returns the date as RFC822 string.
This commit is contained in:
parent
ddde8f26e8
commit
c2d30a07e9
|
@ -76,6 +76,9 @@ extern "C"
|
|||
FREERDP_API char* freerdp_certificate_get_upn(const rdpCertificate* certificate);
|
||||
FREERDP_API char* freerdp_certificate_get_email(const rdpCertificate* certificate);
|
||||
|
||||
FREERDP_API char* freerdp_certificate_get_validity(const rdpCertificate* certificate,
|
||||
BOOL startDate);
|
||||
|
||||
FREERDP_API WINPR_MD_TYPE freerdp_certificate_get_signature_alg(const rdpCertificate* cert);
|
||||
|
||||
FREERDP_API char* freerdp_certificate_get_common_name(const rdpCertificate* cert,
|
||||
|
|
|
@ -1507,6 +1507,12 @@ char* freerdp_certificate_get_email(const rdpCertificate* cert)
|
|||
return x509_utils_get_email(cert->x509);
|
||||
}
|
||||
|
||||
char* freerdp_certificate_get_validity(const rdpCertificate* cert, BOOL startDate)
|
||||
{
|
||||
WINPR_ASSERT(cert);
|
||||
return x509_utils_get_date(cert->x509, startDate);
|
||||
}
|
||||
|
||||
BOOL freerdp_certificate_check_eku(const rdpCertificate* cert, int nid)
|
||||
{
|
||||
WINPR_ASSERT(cert);
|
||||
|
|
|
@ -463,6 +463,33 @@ char* x509_utils_get_upn(const X509* x509)
|
|||
return result;
|
||||
}
|
||||
|
||||
char* x509_utils_get_date(const X509* x509, BOOL startDate)
|
||||
{
|
||||
WINPR_ASSERT(x509);
|
||||
|
||||
const ASN1_TIME* date = startDate ? X509_get0_notBefore(x509) : X509_get0_notAfter(x509);
|
||||
if (!date)
|
||||
return NULL;
|
||||
|
||||
BIO* bmem = BIO_new(BIO_s_mem());
|
||||
if (!bmem)
|
||||
return NULL;
|
||||
|
||||
char* str = NULL;
|
||||
if (ASN1_TIME_print(bmem, date))
|
||||
{
|
||||
BUF_MEM* bptr;
|
||||
|
||||
BIO_get_mem_ptr(bmem, &bptr);
|
||||
str = strndup(bptr->data, bptr->length);
|
||||
}
|
||||
else
|
||||
{ // Log error
|
||||
}
|
||||
BIO_free_all(bmem);
|
||||
return str;
|
||||
}
|
||||
|
||||
void x509_utils_dns_names_free(size_t count, size_t* lengths, char** dns_names)
|
||||
{
|
||||
free(lengths);
|
||||
|
|
|
@ -44,6 +44,7 @@ extern "C"
|
|||
FREERDP_LOCAL char* x509_utils_get_issuer(const X509* xcert);
|
||||
FREERDP_LOCAL char* x509_utils_get_email(const X509* x509);
|
||||
FREERDP_LOCAL char* x509_utils_get_upn(const X509* x509);
|
||||
FREERDP_LOCAL char* x509_utils_get_date(const X509* x509, BOOL startDate);
|
||||
|
||||
FREERDP_LOCAL char* x509_utils_get_common_name(const X509* xcert, size_t* plength);
|
||||
FREERDP_LOCAL char** x509_utils_get_dns_names(const X509* xcert, size_t* count,
|
||||
|
|
Loading…
Reference in New Issue