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=ASN1_INTEGER_new()) == NULL)
+ if ((x->cert_info->version=M_ASN1_INTEGER_new()) == NULL)
return(0);
}
return(ASN1_INTEGER_set(x->cert_info->version,version));
in=x->cert_info->serialNumber;
if (in != serial)
{
- in=ASN1_INTEGER_dup(serial);
+ in=M_ASN1_INTEGER_dup(serial);
if (in != NULL)
{
- ASN1_INTEGER_free(x->cert_info->serialNumber);
+ M_ASN1_INTEGER_free(x->cert_info->serialNumber);
x->cert_info->serialNumber=in;
}
}
return(X509_NAME_set(&x->cert_info->subject,name));
}
-int X509_set_notBefore(X509 *x, ASN1_UTCTIME *tm)
+int X509_set_notBefore(X509 *x, const ASN1_TIME *tm)
{
- ASN1_UTCTIME *in;
+ ASN1_TIME *in;
if ((x == NULL) || (x->cert_info->validity == NULL)) return(0);
in=x->cert_info->validity->notBefore;
if (in != tm)
{
- in=ASN1_UTCTIME_dup(tm);
+ in=M_ASN1_TIME_dup(tm);
if (in != NULL)
{
- ASN1_UTCTIME_free(x->cert_info->validity->notBefore);
+ M_ASN1_TIME_free(x->cert_info->validity->notBefore);
x->cert_info->validity->notBefore=in;
}
}
return(in != NULL);
}
-int X509_set_notAfter(X509 *x, ASN1_UTCTIME *tm)
+int X509_set_notAfter(X509 *x, const ASN1_TIME *tm)
{
- ASN1_UTCTIME *in;
+ ASN1_TIME *in;
if ((x == NULL) || (x->cert_info->validity == NULL)) return(0);
in=x->cert_info->validity->notAfter;
if (in != tm)
{
- in=ASN1_UTCTIME_dup(tm);
+ in=M_ASN1_TIME_dup(tm);
if (in != NULL)
{
- ASN1_UTCTIME_free(x->cert_info->validity->notAfter);
+ M_ASN1_TIME_free(x->cert_info->validity->notAfter);
x->cert_info->validity->notAfter=in;
}
}