RT1909: Omit version for v1 certificates
[oweals/openssl.git] / crypto / x509 / x509_set.c
index 4b94fc58477f68af554a0698f685ec99fc434bb9..d37adb1fbf162a55a13c887f277945648c184770 100644 (file)
 int X509_set_version(X509 *x, long version)
        {
        if (x == NULL) return(0);
+       if (version == 0)
+               {
+               M_ASN1_INTEGER_free(x->cert_info->version);
+               x->cert_info->version = NULL;
+               return(1);
+               }
        if (x->cert_info->version == NULL)
                {
                if ((x->cert_info->version=M_ASN1_INTEGER_new()) == NULL)