Use X509 CRT version macros for version checks in x509write_crt_der
diff --git a/library/x509write_crt.c b/library/x509write_crt.c
index 2061fa0..0af23d7 100644
--- a/library/x509write_crt.c
+++ b/library/x509write_crt.c
@@ -334,7 +334,7 @@
*/
/* Only for v3 */
- if( ctx->version == 2 )
+ if( ctx->version == MBEDTLS_X509_CRT_VERSION_3 )
{
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_extensions( &c, tmp_buf, ctx->extensions ) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) );
@@ -397,7 +397,7 @@
*/
/* Can be omitted for v1 */
- if( ctx->version > 0 )
+ if( ctx->version != MBEDTLS_X509_CRT_VERSION_1 )
{
sub_len = 0;
MBEDTLS_ASN1_CHK_ADD( sub_len, mbedtls_asn1_write_int( &c, tmp_buf, ctx->version ) );