Change in openvpn[master]: Add unit test for printing various details of certificates
A message that is not in the archive (sent off-list or not yet received): gerrit.1774974242000.Iacbd8195cdedc7226bddc686ca8dccf9f25f8842@...2715...
plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email )
Change subject: Add unit test for printing various details of certificates
......................................................................
Add unit test for printing various details of certificates
These unit tests will ensure that refactoring of these methods does not change the output.
Change-Id: Iacbd8195cdedc7226bddc686ca8dccf9f25f8842
---
M tests/unit_tests/openvpn/test_ssl.c
1 file changed, 82 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/1598/1
tests/unit_tests/openvpn/test_ssl.c +82 -1
@@ -46,7 +46,9 @@#include "test_common.h" #include "ssl.h" #include "buffer.h" +#include "cert_data.h" #include "packet_id.h" +#include "ssl_verify.h" /* Mock function to be allowed to include win32.c which is required for * getting the temp directory */
@@ -750,6 +752,83 @@test_data_channel_known_vectors_run (false); } +#if defined(ENABLE_CRYPTO_MBEDTLS ) +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +mbedtls_x509_crt *cert; +ALLOC_OBJ_CLEAR (cert, mbedtls_x509_crt); +int ret =mbedtls_x509_crt_parse (cert, (const unsigned char *)cert_str, +strlen (cert_str) +1 ); + +assert_int_equal (ret,0 ); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +mbedtls_x509_crt_free (cert); +free (cert); +} +#else +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +BIO *in =BIO_new_mem_buf ((char *)cert1,-1 ); +assert_non_null (in); +X509 *cert =PEM_read_bio_X509 (in,NULL ,NULL ,NULL ); +assert_non_null (cert); +BIO_free (in); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +X509_free (cert); +} +#endif + +void +crypto_test_print_cert_details (void **state) +{ +openvpn_x509_cert_t *cert =get_certificate (cert1); +struct gc_arena gc =gc_new (); + +const char *fp =backend_x509_get_serial_hex (cert, &gc); + +/* we messed this up between TLS libraries. But let's at least notice in +* the future ...*/ +#if defined(ENABLE_CRYPTO_MBEDTLS ) +assert_string_equal (fp,"82:6B:DD:CC:BD:E5:5E:B7:08:F1:2D:68:00:3C:24:DE" ); +#else +assert_string_equal (fp,"82:6b:dd:cc:bd:e5:5e:b7:08:f1:2d:68:00:3c:24:de" ); +#endif + +const char *sn =backend_x509_get_serial (cert, &gc); +assert_string_equal (sn,"173359713849739808110610111821055272158" ); + +char username[TLS_USERNAME_LEN +1 ] = {0 };/* null-terminated */ + +int ret =backend_x509_get_username (username,sizeof (username),"CN" , + cert); + +assert_string_equal (username,"ovpn-test-ec1" ); +assert_int_equal (ret,SUCCESS ); + +#ifndef ENABLE_CRYPTO_MBEDTLS +/* mbed TLS does not implement this */ + ret =backend_x509_get_username (username,sizeof (username),"serialNumber" , + cert); +assert_int_equal (ret,SUCCESS ); +assert_string_equal (username,"0x826BDDCCBDE55EB708F12D68003C24DE" ); +#endif + +gc_free (&gc); +free_certificate (cert); +} +int main (void )
@@ -773,7 +852,9 @@cmocka_unit_test (test_data_channel_roundtrip_aes_256_cbc),cmocka_unit_test (test_data_channel_roundtrip_bf_cbc),cmocka_unit_test (test_data_channel_known_vectors_epoch), - cmocka_unit_test(test_data_channel_known_vectors_shortpktid) +cmocka_unit_test (test_data_channel_known_vectors_shortpktid), + cmocka_unit_test(crypto_test_print_cert_details) + };#if defined(ENABLE_CRYPTO_OPENSSL )
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iacbd8195cdedc7226bddc686ca8dccf9f25f8842
Gerrit-Change-Number: 1598
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email )
Change subject: Add unit test for printing various details of certificates
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iacbd8195cdedc7226bddc686ca8dccf9f25f8842
Gerrit-Change-Number: 1598
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Tue, 31 Mar 2026 16:34:06 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Attention is currently required from: flichtenheld, plaisthos.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
Change subject: Add unit test for printing various details of certificates
......................................................................
Add unit test for printing various details of certificates
These unit tests will ensure that refactoring of these methods does not change the output.
---
M tests/unit_tests/openvpn/test_ssl.c
1 file changed, 82 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/1598/2
tests/unit_tests/openvpn/test_ssl.c +82 -1
@@ -46,7 +46,9 @@#include "test_common.h" #include "ssl.h" #include "buffer.h" +#include "cert_data.h" #include "packet_id.h" +#include "ssl_verify.h" /* Mock function to be allowed to include win32.c which is required for * getting the temp directory */
@@ -750,6 +752,83 @@test_data_channel_known_vectors_run (false); } +#if defined(ENABLE_CRYPTO_MBEDTLS ) +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +mbedtls_x509_crt *cert; +ALLOC_OBJ_CLEAR (cert, mbedtls_x509_crt); +int ret =mbedtls_x509_crt_parse (cert, (const unsigned char *)cert_str, +strlen (cert_str) +1 ); + +assert_int_equal (ret,0 ); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +mbedtls_x509_crt_free (cert); +free (cert); +} +#else +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +BIO *in =BIO_new_mem_buf ((char *)cert1,-1 ); +assert_non_null (in); +X509 *cert =PEM_read_bio_X509 (in,NULL ,NULL ,NULL ); +assert_non_null (cert); +BIO_free (in); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +X509_free (cert); +} +#endif + +void +crypto_test_print_cert_details (void **state) +{ +openvpn_x509_cert_t *cert =get_certificate (cert1); +struct gc_arena gc =gc_new (); + +const char *fp =backend_x509_get_serial_hex (cert, &gc); + +/* we messed this up between TLS libraries. But let's at least notice in +* the future ...*/ +#if defined(ENABLE_CRYPTO_MBEDTLS ) +assert_string_equal (fp,"82:6B:DD:CC:BD:E5:5E:B7:08:F1:2D:68:00:3C:24:DE" ); +#else +assert_string_equal (fp,"82:6b:dd:cc:bd:e5:5e:b7:08:f1:2d:68:00:3c:24:de" ); +#endif + +const char *sn =backend_x509_get_serial (cert, &gc); +assert_string_equal (sn,"173359713849739808110610111821055272158" ); + +char username[TLS_USERNAME_LEN +1 ] = {0 };/* null-terminated */ + +int ret =backend_x509_get_username (username,sizeof (username),"CN" , + cert); + +assert_string_equal (username,"ovpn-test-ec1" ); +assert_int_equal (ret,SUCCESS ); + +#ifndef ENABLE_CRYPTO_MBEDTLS +/* mbed TLS does not implement this */ + ret =backend_x509_get_username (username,sizeof (username),"serialNumber" , + cert); +assert_int_equal (ret,SUCCESS ); +assert_string_equal (username,"0x826BDDCCBDE55EB708F12D68003C24DE" ); +#endif + +gc_free (&gc); +free_certificate (cert); +} +int main (void )
@@ -773,7 +852,9 @@cmocka_unit_test (test_data_channel_roundtrip_aes_256_cbc),cmocka_unit_test (test_data_channel_roundtrip_bf_cbc),cmocka_unit_test (test_data_channel_known_vectors_epoch), - cmocka_unit_test(test_data_channel_known_vectors_shortpktid) +cmocka_unit_test (test_data_channel_known_vectors_shortpktid), + cmocka_unit_test(crypto_test_print_cert_details) + };#if defined(ENABLE_CRYPTO_OPENSSL )
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iacbd8195cdedc7226bddc686ca8dccf9f25f8842
Gerrit-Change-Number: 1598
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
PATCH v2 1/1 Add unit test for printing various details of certificates
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
These unit tests will ensure that refactoring of these methods does not change the output.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1598
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1598
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
tests/unit_tests/openvpn/test_ssl.c +82 -1
@@ -46,7 +46,9 @@#include "test_common.h" #include "ssl.h" #include "buffer.h" +#include "cert_data.h" #include "packet_id.h" +#include "ssl_verify.h" /* Mock function to be allowed to include win32.c which is required for * getting the temp directory */
@@ -750,6 +752,83 @@test_data_channel_known_vectors_run (false); } +#if defined(ENABLE_CRYPTO_MBEDTLS ) +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +mbedtls_x509_crt *cert; +ALLOC_OBJ_CLEAR (cert, mbedtls_x509_crt); +int ret =mbedtls_x509_crt_parse (cert, (const unsigned char *)cert_str, +strlen (cert_str) +1 ); + +assert_int_equal (ret,0 ); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +mbedtls_x509_crt_free (cert); +free (cert); +} +#else +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +BIO *in =BIO_new_mem_buf ((char *)cert1,-1 ); +assert_non_null (in); +X509 *cert =PEM_read_bio_X509 (in,NULL ,NULL ,NULL ); +assert_non_null (cert); +BIO_free (in); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +X509_free (cert); +} +#endif + +void +crypto_test_print_cert_details (void **state) +{ +openvpn_x509_cert_t *cert =get_certificate (cert1); +struct gc_arena gc =gc_new (); + +const char *fp =backend_x509_get_serial_hex (cert, &gc); + +/* we messed this up between TLS libraries. But let's at least notice in +* the future ...*/ +#if defined(ENABLE_CRYPTO_MBEDTLS ) +assert_string_equal (fp,"82:6B:DD:CC:BD:E5:5E:B7:08:F1:2D:68:00:3C:24:DE" ); +#else +assert_string_equal (fp,"82:6b:dd:cc:bd:e5:5e:b7:08:f1:2d:68:00:3c:24:de" ); +#endif + +const char *sn =backend_x509_get_serial (cert, &gc); +assert_string_equal (sn,"173359713849739808110610111821055272158" ); + +char username[TLS_USERNAME_LEN +1 ] = {0 };/* null-terminated */ + +int ret =backend_x509_get_username (username,sizeof (username),"CN" , + cert); + +assert_string_equal (username,"ovpn-test-ec1" ); +assert_int_equal (ret,SUCCESS ); + +#ifndef ENABLE_CRYPTO_MBEDTLS +/* mbed TLS does not implement this */ + ret =backend_x509_get_username (username,sizeof (username),"serialNumber" , + cert); +assert_int_equal (ret,SUCCESS ); +assert_string_equal (username,"0x826BDDCCBDE55EB708F12D68003C24DE" ); +#endif + +gc_free (&gc); +free_certificate (cert); +} +int main (void )
@@ -773,7 +852,9 @@cmocka_unit_test (test_data_channel_roundtrip_aes_256_cbc),cmocka_unit_test (test_data_channel_roundtrip_bf_cbc),cmocka_unit_test (test_data_channel_known_vectors_epoch), - cmocka_unit_test(test_data_channel_known_vectors_shortpktid) +cmocka_unit_test (test_data_channel_known_vectors_shortpktid), + cmocka_unit_test(crypto_test_print_cert_details) + };#if defined(ENABLE_CRYPTO_OPENSSL )
[Openvpn-devel] [PATCH applied] Re: Add unit test for printing various details of certificates
Extra unit tests are always welcome :-) - and as such, go to release/2.7 as well (especially since I think upcoming OSSL 4 compat patches will benefit from having these unit tests).
Stared a bit at the code, tested the 2.7 version on Linux with OSSL 3, passes...
[ RUN ] crypto_test_print_cert_details
[ OK ] crypto_test_print_cert_details
[==========] ssl tests: 18 test(s) run.
Your patch has been applied to the master and release/2.7 branch.
commit 27d1b9a0da73c40db73cbe9000aef31d14dd5c92 (master) commit 490364ce09f72fb68518d619b41807b7af445954 (release/2.7)
Author: Arne Schwabe Date: Tue Mar 31 19:33:57 2026 +0200
Add unit test for printing various details of certificates
Signed-off-by: Arne Schwabe <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1598
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36389.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email )
Change subject: Add unit test for printing various details of certificates
......................................................................
Patch Set 3: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iacbd8195cdedc7226bddc686ca8dccf9f25f8842
Gerrit-Change-Number: 1598
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Wed, 01 Apr 2026 10:20:21 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
cron2 has uploaded a new patch set (#4) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
Change subject: Add unit test for printing various details of certificates
......................................................................
Add unit test for printing various details of certificates
These unit tests will ensure that refactoring of these methods does not change the output.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1598
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36389.html
---
M tests/unit_tests/openvpn/test_ssl.c
1 file changed, 82 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/98/1598/4
tests/unit_tests/openvpn/test_ssl.c +82 -1
@@ -46,7 +46,9 @@#include "test_common.h" #include "ssl.h" #include "buffer.h" +#include "cert_data.h" #include "packet_id.h" +#include "ssl_verify.h" /* Mock function to be allowed to include win32.c which is required for * getting the temp directory */
@@ -750,6 +752,83 @@test_data_channel_known_vectors_run (false); } +#if defined(ENABLE_CRYPTO_MBEDTLS ) +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +mbedtls_x509_crt *cert; +ALLOC_OBJ_CLEAR (cert, mbedtls_x509_crt); +int ret =mbedtls_x509_crt_parse (cert, (const unsigned char *)cert_str, +strlen (cert_str) +1 ); + +assert_int_equal (ret,0 ); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +mbedtls_x509_crt_free (cert); +free (cert); +} +#else +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +BIO *in =BIO_new_mem_buf ((char *)cert1,-1 ); +assert_non_null (in); +X509 *cert =PEM_read_bio_X509 (in,NULL ,NULL ,NULL ); +assert_non_null (cert); +BIO_free (in); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +X509_free (cert); +} +#endif + +void +crypto_test_print_cert_details (void **state) +{ +openvpn_x509_cert_t *cert =get_certificate (cert1); +struct gc_arena gc =gc_new (); + +const char *fp =backend_x509_get_serial_hex (cert, &gc); + +/* we messed this up between TLS libraries. But let's at least notice in +* the future ...*/ +#if defined(ENABLE_CRYPTO_MBEDTLS ) +assert_string_equal (fp,"82:6B:DD:CC:BD:E5:5E:B7:08:F1:2D:68:00:3C:24:DE" ); +#else +assert_string_equal (fp,"82:6b:dd:cc:bd:e5:5e:b7:08:f1:2d:68:00:3c:24:de" ); +#endif + +const char *sn =backend_x509_get_serial (cert, &gc); +assert_string_equal (sn,"173359713849739808110610111821055272158" ); + +char username[TLS_USERNAME_LEN +1 ] = {0 };/* null-terminated */ + +int ret =backend_x509_get_username (username,sizeof (username),"CN" , + cert); + +assert_string_equal (username,"ovpn-test-ec1" ); +assert_int_equal (ret,SUCCESS ); + +#ifndef ENABLE_CRYPTO_MBEDTLS +/* mbed TLS does not implement this */ + ret =backend_x509_get_username (username,sizeof (username),"serialNumber" , + cert); +assert_int_equal (ret,SUCCESS ); +assert_string_equal (username,"0x826BDDCCBDE55EB708F12D68003C24DE" ); +#endif + +gc_free (&gc); +free_certificate (cert); +} +int main (void )
@@ -773,7 +852,9 @@cmocka_unit_test (test_data_channel_roundtrip_aes_256_cbc),cmocka_unit_test (test_data_channel_roundtrip_bf_cbc),cmocka_unit_test (test_data_channel_known_vectors_epoch), - cmocka_unit_test(test_data_channel_known_vectors_shortpktid) +cmocka_unit_test (test_data_channel_known_vectors_shortpktid), + cmocka_unit_test(crypto_test_print_cert_details) + };#if defined(ENABLE_CRYPTO_OPENSSL )
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iacbd8195cdedc7226bddc686ca8dccf9f25f8842
Gerrit-Change-Number: 1598
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email )
Change subject: Add unit test for printing various details of certificates
......................................................................
Add unit test for printing various details of certificates
These unit tests will ensure that refactoring of these methods does not change the output.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1598
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36389.html
---
M tests/unit_tests/openvpn/test_ssl.c
1 file changed, 82 insertions(+), 1 deletion(-)
tests/unit_tests/openvpn/test_ssl.c +82 -1
@@ -46,7 +46,9 @@#include "test_common.h" #include "ssl.h" #include "buffer.h" +#include "cert_data.h" #include "packet_id.h" +#include "ssl_verify.h" /* Mock function to be allowed to include win32.c which is required for * getting the temp directory */
@@ -750,6 +752,83 @@test_data_channel_known_vectors_run (false); } +#if defined(ENABLE_CRYPTO_MBEDTLS ) +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +mbedtls_x509_crt *cert; +ALLOC_OBJ_CLEAR (cert, mbedtls_x509_crt); +int ret =mbedtls_x509_crt_parse (cert, (const unsigned char *)cert_str, +strlen (cert_str) +1 ); + +assert_int_equal (ret,0 ); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +mbedtls_x509_crt_free (cert); +free (cert); +} +#else +static openvpn_x509_cert_t * +get_certificate (const char *cert_str) +{ +BIO *in =BIO_new_mem_buf ((char *)cert1,-1 ); +assert_non_null (in); +X509 *cert =PEM_read_bio_X509 (in,NULL ,NULL ,NULL ); +assert_non_null (cert); +BIO_free (in); +return cert; +} + +static void +free_certificate (openvpn_x509_cert_t *cert) +{ +X509_free (cert); +} +#endif + +void +crypto_test_print_cert_details (void **state) +{ +openvpn_x509_cert_t *cert =get_certificate (cert1); +struct gc_arena gc =gc_new (); + +const char *fp =backend_x509_get_serial_hex (cert, &gc); + +/* we messed this up between TLS libraries. But let's at least notice in +* the future ...*/ +#if defined(ENABLE_CRYPTO_MBEDTLS ) +assert_string_equal (fp,"82:6B:DD:CC:BD:E5:5E:B7:08:F1:2D:68:00:3C:24:DE" ); +#else +assert_string_equal (fp,"82:6b:dd:cc:bd:e5:5e:b7:08:f1:2d:68:00:3c:24:de" ); +#endif + +const char *sn =backend_x509_get_serial (cert, &gc); +assert_string_equal (sn,"173359713849739808110610111821055272158" ); + +char username[TLS_USERNAME_LEN +1 ] = {0 };/* null-terminated */ + +int ret =backend_x509_get_username (username,sizeof (username),"CN" , + cert); + +assert_string_equal (username,"ovpn-test-ec1" ); +assert_int_equal (ret,SUCCESS ); + +#ifndef ENABLE_CRYPTO_MBEDTLS +/* mbed TLS does not implement this */ + ret =backend_x509_get_username (username,sizeof (username),"serialNumber" , + cert); +assert_int_equal (ret,SUCCESS ); +assert_string_equal (username,"0x826BDDCCBDE55EB708F12D68003C24DE" ); +#endif + +gc_free (&gc); +free_certificate (cert); +} +int main (void )
@@ -773,7 +852,9 @@cmocka_unit_test (test_data_channel_roundtrip_aes_256_cbc),cmocka_unit_test (test_data_channel_roundtrip_bf_cbc),cmocka_unit_test (test_data_channel_known_vectors_epoch), - cmocka_unit_test(test_data_channel_known_vectors_shortpktid) +cmocka_unit_test (test_data_channel_known_vectors_shortpktid), + cmocka_unit_test(crypto_test_print_cert_details) + };#if defined(ENABLE_CRYPTO_OPENSSL )
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1598?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Iacbd8195cdedc7226bddc686ca8dccf9f25f8842
Gerrit-Change-Number: 1598
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>