fprintf(stderr, "global_init: %s\n", gnutls_strerror(ret));
exit(1);
}
+
+ memset(&cinfo, 0, sizeof(cinfo));
#ifdef ENABLE_PKCS11
if (HAVE_OPT(PROVIDER)) {
ret = gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL);
}
}
- pkcs11_common();
+ pkcs11_common(&cinfo);
#endif
- memset(&cinfo, 0, sizeof(cinfo));
-
if (HAVE_OPT(VERBOSE))
cinfo.verbose = 1;
+ cinfo.batch = batch;
cinfo.cprint = HAVE_OPT(CPRINT);
if (HAVE_OPT(LOAD_PRIVKEY))
size_t pin_max)
{
const char *password = NULL;
+ common_info_st *info = user;
const char *desc;
int cache = MAX_CACHE_TRIES;
unsigned len;
printf("Token '%s' with URL '%s' ", token_label, token_url);
printf("requires %s PIN\n", desc);
-
+
password = getenv(env);
if (env == NULL) /* compatibility */
password = getenv("GNUTLS_PIN");
- if (password == NULL) {
+ if (password == NULL && (info == NULL || info->batch == 0)) {
password = getpass("Enter PIN: ");
} else {
if (flags & GNUTLS_PIN_WRONG) {
token_callback(void *user, const char *label, const unsigned retry)
{
char buf[32];
+ common_info_st *info = user;
- if (retry > 0) {
+ if (retry > 0 || (info != NULL && info->batch != 0)) {
fprintf(stderr, "Could not find token %s\n", label);
return -1;
}
return 0;
}
-void pkcs11_common(void)
+void pkcs11_common(common_info_st *c)
{
- gnutls_pkcs11_set_pin_function(pin_callback, NULL);
- gnutls_pkcs11_set_token_function(token_callback, NULL);
+ gnutls_pkcs11_set_pin_function(pin_callback, c);
+ gnutls_pkcs11_set_token_function(token_callback, c);
}
#include <config.h>
#include <gnutls/gnutls.h>
+#include <certtool-common.h>
#include <sys/socket.h>
#include <netdb.h>
int cert_verify(gnutls_session_t session, const char *hostname, const char *purpose);
const char *raw_to_string(const unsigned char *raw, size_t raw_size);
-void pkcs11_common(void);
int check_command(gnutls_session_t session, const char *str);
int
const char *token_label, unsigned int flags, char *pin,
size_t pin_max);
-void pkcs11_common(void);
+void pkcs11_common(common_info_st *c);
#ifdef _WIN32
static int system_recv_timeout(gnutls_transport_ptr_t ptr, unsigned int ms)
exit(1);
}
#ifdef ENABLE_PKCS11
- pkcs11_common();
+ pkcs11_common(NULL);
#endif
memset(&cinfo, 0, sizeof(cinfo));
if (login_flags) obj_flags = login_flags;
- pkcs11_common();
+ pkcs11_common(info);
FIX(url, outfile, detailed, info);
if (login_flags) obj_flags = login_flags;
- pkcs11_common();
+ pkcs11_common(info);
FIX(url, outfile, 0, info);
if (login_flags) obj_flags = login_flags;
- pkcs11_common();
+ pkcs11_common(info);
FIX(url, outfile, 0, info);
int ret;
char *url = NULL, *t = NULL;
- pkcs11_common();
+ pkcs11_common(info);
ret = gnutls_pkcs11_token_get_url(0, 0, &url);
if (ret < 0)
char buf[128];
size_t size;
- pkcs11_common();
+ pkcs11_common(info);
for (i = 0;; i++) {
ret = gnutls_pkcs11_token_get_url(i, detailed, &url);
if (login_flags) flags = login_flags;
- pkcs11_common();
+ pkcs11_common(info);
FIX(url, outfile, 0, info);
CHECK_LOGIN_FLAG(login_flags);
if (login_flags) flags = login_flags;
- pkcs11_common();
+ pkcs11_common(info);
FIX(url, outfile, detailed, info);
CHECK_LOGIN_FLAG(login_flags);
const char *pin;
char so_pin[32];
- pkcs11_common();
+ pkcs11_common(info);
if (url == NULL) {
fprintf(stderr, "error: no token URL given to initialize!\n");
unsigned long mechanism;
const char *str;
- pkcs11_common();
+ pkcs11_common(info);
FIX(url, outfile, 0, info);
int ret;
uint8_t *output;
- pkcs11_common();
+ pkcs11_common(info);
FIX(url, outfile, 0, info);
exit(1);
}
#ifdef ENABLE_PKCS11
- pkcs11_common();
+ pkcs11_common(NULL);
#endif
/* Note that servers must generate parameters for