]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Certtool can now write more than a single crl_dist_point.
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 19 Mar 2014 10:37:01 +0000 (11:37 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Wed, 19 Mar 2014 10:37:01 +0000 (11:37 +0100)
src/certtool-cfg.c
src/certtool-cfg.h
src/certtool.c

index 2c84d35db57a7f9ef5dd57f58e6e8957633626a2..fbc1f6833efb4e59e597d5e0dc179cdb75098632 100644 (file)
@@ -80,7 +80,7 @@ typedef struct _cfg_ctx {
        char **excluded_nc_dns;
        char **permitted_nc_email;
        char **excluded_nc_email;
-       char *crl_dist_points;
+       char **crl_dist_points;
        char *password;
        char *pkcs12_key_name;
        char *expiration_date;
@@ -296,9 +296,7 @@ int template_parse(const char *template)
 
        READ_MULTI_LINE_TOKENIZED("dn_oid", cfg.dn_oid);
 
-       val = optionGetValue(pov, "crl_dist_points");
-       if (val != NULL && val->valType == OPARG_TYPE_STRING)
-               cfg.crl_dist_points = strdup(val->v.strVal);
+       READ_MULTI_LINE("crl_dist_points", cfg.crl_dist_points);
 
        val = optionGetValue(pov, "pkcs12_key_name");
        if (val != NULL && val->valType == OPARG_TYPE_STRING)
@@ -513,14 +511,42 @@ const char *get_challenge_pass(void)
                return getpass("Enter a challenge password: ");
 }
 
-const char *get_crl_dist_point_url(void)
+void get_crl_dist_point_set(gnutls_x509_crt_t crt)
 {
-       if (batch)
-               return cfg.crl_dist_points;
-       else
-               return
-                   read_str
-                   ("Enter the URI of the CRL distribution point: ");
+       int ret = 0, i;
+
+       if (batch) {
+               if (!cfg.crl_dist_points)
+                       return;
+
+               for (i = 0; cfg.crl_dist_points[i] != NULL; i++) {
+                       ret =
+                           gnutls_x509_crt_set_crl_dist_points
+                           (crt, GNUTLS_SAN_URI, cfg.crl_dist_points[i],
+                            0);
+                       if (ret < 0)
+                               break;
+               }
+       } else {
+               const char *p;
+
+               do {
+                       p = read_str
+                           ("Enter the URI of the CRL distribution point: ");
+                       if (!p)
+                               return;
+
+                       ret = gnutls_x509_crt_set_crl_dist_points
+                           (crt, GNUTLS_SAN_URI, p, 0);
+               }
+               while (p);
+       }
+
+       if (ret < 0) {
+               fprintf(stderr, "gnutls_x509_crt_set_crl_dist_points: %s\n",
+                       gnutls_strerror(ret));
+               exit(1);
+       }
 }
 
 void get_country_crt_set(gnutls_x509_crt_t crt)
index 8c141d6658679ae307e82097e30f52590ae8267e..b7069272d7cabb69b005b1753f50d540fdc43aa7 100644 (file)
@@ -37,7 +37,7 @@ int read_yesno(const char *input_str, int def);
 const char *get_pass(void);
 const char *get_confirmed_pass(bool empty_ok);
 const char *get_challenge_pass(void);
-const char *get_crl_dist_point_url(void);
+void get_crl_dist_point_set(gnutls_x509_crt_t crt);
 void crt_constraints_set(gnutls_x509_crt_t crt);
 void get_country_crt_set(gnutls_x509_crt_t crt);
 void get_organization_crt_set(gnutls_x509_crt_t crt);
index 877cc9c34a041f1e5401e7943a455a3f898dcc63..4b628394d4499c11f84c7b7c6bd22f2db3eba3d7 100644 (file)
@@ -758,7 +758,6 @@ void generate_self_signed(common_info_st * cinfo)
        gnutls_privkey_t key;
        size_t size;
        int result;
-       const char *uri;
 
        fprintf(stderr, "Generating a self signed certificate...\n");
 
@@ -767,16 +766,7 @@ void generate_self_signed(common_info_st * cinfo)
        if (!key)
                key = load_private_key(1, cinfo);
 
-       uri = get_crl_dist_point_url();
-       if (uri) {
-               result = gnutls_x509_crt_set_crl_dist_points(crt, GNUTLS_SAN_URI, uri, 0        /* all reasons */
-                   );
-               if (result < 0) {
-                       fprintf(stderr, "crl_dist_points: %s\n",
-                               gnutls_strerror(result));
-                       exit(1);
-               }
-       }
+       get_crl_dist_point_set(crt);
 
        print_certificate_info(crt, stderr, 0);