]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
set the key purpose in certificate requests
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 2 May 2013 17:57:47 +0000 (20:57 +0300)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 2 May 2013 17:58:37 +0000 (20:58 +0300)
src/certtool-cfg.c
src/certtool-cfg.h
src/certtool.c

index f81914bf33f7f5840a69a9b13a6c1cca42d0a99a..3edd151d9215b7cee6b1b6a7c72cc84325bca3d8 100644 (file)
@@ -748,7 +748,7 @@ get_oid_crt_set (gnutls_x509_crt_t crt)
 }
 
 void
-get_key_purpose_set (gnutls_x509_crt_t crt)
+get_key_purpose_set (int type, void *crt)
 {
   int ret, i;
 
@@ -758,9 +758,12 @@ get_key_purpose_set (gnutls_x509_crt_t crt)
         return;
       for (i = 0; cfg.key_purpose_oids[i] != NULL; i++)
         {
-          ret =
-            gnutls_x509_crt_set_key_purpose_oid (crt, cfg.key_purpose_oids[i],
-                                                 0);
+          if (type == TYPE_CRT)
+            ret =
+              gnutls_x509_crt_set_key_purpose_oid (crt, cfg.key_purpose_oids[i], 0);
+          else
+            ret =
+              gnutls_x509_crq_set_key_purpose_oid (crt, cfg.key_purpose_oids[i], 0);
 
           if (ret < 0)
             {
index cbfa896e05440156c1acc80117939de8703cc6f8..98f42993d25c94cd6c69b977257eed5c3eaaf183 100644 (file)
@@ -49,7 +49,7 @@ void get_dn_crq_set (gnutls_x509_crq_t crt);
 void get_uid_crt_set (gnutls_x509_crt_t crt);
 void get_pkcs9_email_crt_set (gnutls_x509_crt_t crt);
 void get_oid_crt_set (gnutls_x509_crt_t crt);
-void get_key_purpose_set (gnutls_x509_crt_t crt);
+void get_key_purpose_set (int type, void *crt);
 int get_serial (void);
 int get_days (void);
 int get_ca_status (void);
index 8e4fc6e9331592ff4c564e39cf5452e7e1464951..9cd72cae7753999704efb3c4067f3fad9022c86f 100644 (file)
@@ -288,7 +288,7 @@ generate_certificate (gnutls_privkey_t * ret_key,
           get_dc_set (TYPE_CRT, crt);
 
           get_oid_crt_set (crt);
-          get_key_purpose_set (crt);
+          get_key_purpose_set (TYPE_CRT, crt);
 
           if (!batch)
             fprintf (stderr,
@@ -1909,6 +1909,8 @@ generate_request (common_info_st * cinfo)
           if (ret < 0)
             error (EXIT_FAILURE, 0, "key_kp: %s", gnutls_strerror (ret));
         }
+
+      get_key_purpose_set (TYPE_CRQ, crq);
     }
 
   ret = gnutls_x509_crq_set_pubkey (crq, pubkey);