summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-04-27 14:29:30 +0300
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-04-27 14:32:13 +0300
commit9b6210cbe678ab55eb4c20c3bd81d541aba940b0 (patch)
tree14130ca23a299060ad5a1ce035fe4e87a8b11bc0 /src
parentc159ccb4b91617ea5441a5f516dd1872599cc5a2 (diff)
downloadgnutls-9b6210cbe678ab55eb4c20c3bd81d541aba940b0.tar.gz
read_yesno() accepts a default value. By default certificates are marked as ok for signing and encryption.
Diffstat (limited to 'src')
-rw-r--r--src/certtool-cfg.c49
-rw-r--r--src/certtool-cfg.h2
-rw-r--r--src/certtool.c2
-rw-r--r--src/pkcs11.c2
4 files changed, 30 insertions, 25 deletions
diff --git a/src/certtool-cfg.c b/src/certtool-cfg.c
index 4cace7bb36..f81914bf33 100644
--- a/src/certtool-cfg.c
+++ b/src/certtool-cfg.c
@@ -427,24 +427,29 @@ read_str (const char *input_str)
return input;
}
-/* Default is no
+/* Default is:
+ * def: 0 -> no
+ * def: 1 -> yes
*/
int
-read_yesno (const char *input_str)
+read_yesno (const char *input_str, int def)
{
char input[128];
+restart:
fputs (input_str, stderr);
if (fgets (input, sizeof (input), stdin) == NULL)
- return 0;
+ return def;
if (IS_NEWLINE(input))
- return 0;
+ return def;
if (input[0] == 'y' || input[0] == 'Y')
return 1;
-
- return 0;
+ else if (input[0] == 'n' || input[0] == 'N')
+ return 0;
+ else
+ goto restart;
}
@@ -899,7 +904,7 @@ get_ca_status (void)
else
{
return
- read_yesno ("Does the certificate belong to an authority? (y/N): ");
+ read_yesno ("Does the certificate belong to an authority? (y/N): ", 0);
}
}
@@ -914,7 +919,7 @@ get_crq_extensions_status (void)
{
return
read_yesno
- ("Do you want to honour the extensions from the request? (y/N): ");
+ ("Do you want to honour the extensions from the request? (y/N): ", 0);
}
}
@@ -976,7 +981,7 @@ get_tls_client_status (void)
}
else
{
- return read_yesno ("Is this a TLS web client certificate? (y/N): ");
+ return read_yesno ("Is this a TLS web client certificate? (y/N): ", 0);
}
}
@@ -990,7 +995,7 @@ get_tls_server_status (void)
else
{
return
- read_yesno ("Is this also a TLS web server certificate? (y/N): ");
+ read_yesno ("Is this a TLS web server certificate? (y/N): ", 0);
}
}
@@ -1382,11 +1387,11 @@ get_sign_status (int server)
{
if (server)
msg =
- "Will the certificate be used for signing (DHE and RSA-EXPORT ciphersuites)? (y/N): ";
+ "Will the certificate be used for signing (DHE and RSA-EXPORT ciphersuites)? (Y/n): ";
else
msg =
- "Will the certificate be used for signing (required for TLS)? (y/N): ";
- return read_yesno (msg);
+ "Will the certificate be used for signing (required for TLS)? (Y/n): ";
+ return read_yesno (msg, 1);
}
}
@@ -1403,11 +1408,11 @@ get_encrypt_status (int server)
{
if (server)
msg =
- "Will the certificate be used for encryption (RSA ciphersuites)? (y/N): ";
+ "Will the certificate be used for encryption (RSA ciphersuites)? (Y/n): ";
else
msg =
- "Will the certificate be used for encryption (not required for TLS)? (y/N): ";
- return read_yesno (msg);
+ "Will the certificate be used for encryption (not required for TLS)? (Y/n): ";
+ return read_yesno (msg, 1);
}
}
@@ -1422,7 +1427,7 @@ get_cert_sign_status (void)
{
return
read_yesno
- ("Will the certificate be used to sign other certificates? (y/N): ");
+ ("Will the certificate be used to sign other certificates? (y/N): ", 0);
}
}
@@ -1436,7 +1441,7 @@ get_crl_sign_status (void)
else
{
return
- read_yesno ("Will the certificate be used to sign CRLs? (y/N): ");
+ read_yesno ("Will the certificate be used to sign CRLs? (y/N): ", 0);
}
}
@@ -1450,7 +1455,7 @@ get_code_sign_status (void)
else
{
return
- read_yesno ("Will the certificate be used to sign code? (y/N): ");
+ read_yesno ("Will the certificate be used to sign code? (y/N): ", 0);
}
}
@@ -1465,7 +1470,7 @@ get_ocsp_sign_status (void)
{
return
read_yesno
- ("Will the certificate be used to sign OCSP requests? (y/N): ");
+ ("Will the certificate be used to sign OCSP requests? (y/N): ", 0);
}
}
@@ -1480,7 +1485,7 @@ get_time_stamp_status (void)
{
return
read_yesno
- ("Will the certificate be used for time stamping? (y/N): ");
+ ("Will the certificate be used for time stamping? (y/N): ", 0);
}
}
@@ -1495,7 +1500,7 @@ get_ipsec_ike_status (void)
{
return
read_yesno
- ("Will the certificate be used for IPsec IKE operations? (y/N): ");
+ ("Will the certificate be used for IPsec IKE operations? (y/N): ", 0);
}
}
diff --git a/src/certtool-cfg.h b/src/certtool-cfg.h
index 87b5be1eb4..cbfa896e05 100644
--- a/src/certtool-cfg.h
+++ b/src/certtool-cfg.h
@@ -32,7 +32,7 @@ void read_crq_set (gnutls_x509_crq_t crq, const char *input_str,
const char *oid);
int read_int (const char *input_str);
const char *read_str (const char *input_str);
-int read_yesno (const char *input_str);
+int read_yesno (const char *input_str, int def);
const char *get_pass (void);
const char *get_confirmed_pass (bool empty_ok);
diff --git a/src/certtool.c b/src/certtool.c
index 414587d860..8e4fc6e933 100644
--- a/src/certtool.c
+++ b/src/certtool.c
@@ -1456,7 +1456,7 @@ print_certificate_info (gnutls_x509_crt_t crt, FILE * out, unsigned int all)
}
if (out == stderr && batch == 0) /* interactive */
- if (read_yesno ("Is the above information ok? (y/N): ") == 0)
+ if (read_yesno ("Is the above information ok? (y/N): ", 0) == 0)
{
exit (1);
}
diff --git a/src/pkcs11.c b/src/pkcs11.c
index a8fc41f652..18b96451de 100644
--- a/src/pkcs11.c
+++ b/src/pkcs11.c
@@ -48,7 +48,7 @@ pkcs11_delete (FILE * outfile, const char *url, int batch, unsigned int login,
pkcs11_list (outfile, url, PKCS11_TYPE_ALL, login,
GNUTLS_PKCS11_URL_LIB, info);
ret =
- read_yesno ("Are you sure you want to delete those objects? (y/N): ");
+ read_yesno ("Are you sure you want to delete those objects? (y/N): ", 0);
if (ret == 0)
{
exit (1);