These allow for an non-interactive --initialize process.
unsigned int crq_extensions;
unsigned int v1_cert;
+ const char *pin;
+ const char *so_pin;
+
int cprint;
unsigned int verbose;
doc = "";
};
-flag = {
- name = initialize;
- descrip = "Initializes a PKCS #11 token";
- doc = "";
-};
-
flag = {
name = write;
descrip = "Writes the loaded objects to a PKCS #11 token";
aliases = outder;
};
+flag = {
+ name = initialize;
+ descrip = "Initializes a PKCS #11 token";
+ doc = "";
+};
+
+flag = {
+ name = set-pin;
+ arg-type = string;
+ descrip = "Specify the PIN to use on token initialization";
+ doc = "";
+};
+
+flag = {
+ name = set-so-pin;
+ arg-type = string;
+ descrip = "Specify the Security Officer's PIN to use on token initialization";
+ doc = "";
+};
+
flag = {
name = provider;
arg-type = file;
else
cinfo.outcert_format = GNUTLS_X509_FMT_PEM;
+ if (HAVE_OPT(SET_PIN))
+ cinfo.pin = OPT_ARG(SET_PIN);
+
+ if (HAVE_OPT(SET_SO_PIN))
+ cinfo.so_pin = OPT_ARG(SET_SO_PIN);
+
if (HAVE_OPT(LOAD_CERTIFICATE))
cinfo.cert = OPT_ARG(LOAD_CERTIFICATE);
common_info_st * info)
{
int ret;
- char *pin;
+ const char *pin;
char so_pin[32];
pkcs11_common();
exit(1);
}
- pin = getpass("Enter Security Officer's PIN: ");
- if (pin == NULL)
- exit(1);
+ if (info->so_pin != NULL)
+ pin = info->so_pin;
+ else {
+ pin = getpass("Enter Security Officer's PIN: ");
+ if (pin == NULL)
+ exit(1);
+ }
- if (strlen(pin) >= sizeof(so_pin))
+ if (strlen(pin) >= sizeof(so_pin) || pin[0] == '\n')
exit(1);
strcpy(so_pin, pin);
- pin = getpass("Enter new User's PIN: ");
- if (pin == NULL)
+ if (info->so_pin != NULL)
+ pin = info->pin;
+ else {
+ pin = getpass("Enter new User's PIN: ");
+ if (pin == NULL)
+ exit(1);
+ }
+
+ if (pin[0] == '\n')
exit(1);
ret = gnutls_pkcs11_token_init(url, so_pin, label);