From: Simon Josefsson Date: Tue, 15 Apr 2008 04:29:17 +0000 (+0200) Subject: Make gnutls_x509_crq_sign2 set certificate request version if not set. X-Git-Tag: gnutls_2_3_6~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe8027decd0a46952c81bb9b5e1a16ad3e8da616;p=thirdparty%2Fgnutls.git Make gnutls_x509_crq_sign2 set certificate request version if not set. --- diff --git a/NEWS b/NEWS index c007690883..728046a4ef 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ See the end for copying conditions. * Version 2.3.6 (unreleased) +** Make gnutls_x509_crq_sign2 set certificate request version if not set. ** Improve documentation for gnutls_x509_crq_sign2. Based on report from "John Brooks" in . diff --git a/lib/x509/crq.c b/lib/x509/crq.c index 8ad9963daf..9201709ca4 100644 --- a/lib/x509/crq.c +++ b/lib/x509/crq.c @@ -750,6 +750,17 @@ gnutls_x509_crq_sign2 (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key, return GNUTLS_E_INVALID_REQUEST; } + /* Make sure version field is set. */ + if (gnutls_x509_crq_get_version (crq) == GNUTLS_E_ASN1_VALUE_NOT_FOUND) + { + result = gnutls_x509_crq_set_version (crq, 1); + if (result < 0) + { + gnutls_assert (); + return result; + } + } + /* Step 1. Self sign the request. */ result = diff --git a/src/certtool.c b/src/certtool.c index a6d0c9d578..e8a96c9db3 100644 --- a/src/certtool.c +++ b/src/certtool.c @@ -1752,10 +1752,6 @@ generate_request (void) get_uid_crq_set (crq); get_oid_crq_set (crq); - ret = gnutls_x509_crq_set_version (crq, 1); - if (ret < 0) - error (EXIT_FAILURE, 0, "set_version: %s", gnutls_strerror (ret)); - pass = get_challenge_pass (); if (pass != NULL)