{
case 'h':
return command_usage(NULL);
+ case 'v':
+ dbg_level = atoi(optarg);
+ continue;
case 't':
if (streq(optarg, "rsa"))
{
{"type", 't', 1, "type of key, default: rsa"},
{"size", 's', 1, "keylength in bits, default: rsa 2048, ecdsa 384"},
{"outform", 'f', 1, "encoding of generated private key"},
+ {"debug", 'v', 1, "set debug level, default: 1"},
}
});
}
#include "pki.h"
+#include <debug.h>
#include <utils/linked_list.h>
#include <utils/optionsfrom.h>
#include <credentials/certificates/certificate.h>
{
case 'h':
goto usage;
+ case 'v':
+ dbg_level = atoi(optarg);
+ continue;
case '+':
if (!options->from(options, optarg, &argc, &argv, optind))
{
goto end;
}
}
+
+ DBG2("Reading ca certificate:");
ca = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_FROM_FILE, cacert, BUILD_END);
if (!ca)
error = "CA certificate misses CA basicConstraint";
goto end;
}
-
public = ca->get_public_key(ca);
if (!public)
{
error = "extracting CA certificate public key failed";
goto end;
}
+
+ DBG2("Reading ca private key:");
private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY,
public->get_type(public),
BUILD_FROM_FILE, cakey, BUILD_END);
identification_t *subjectAltName;
pkcs10_t *req;
+ DBG2("Reading certificate request");
if (file)
{
cert_req = lib->creds->create(lib->creds, CRED_CERTIFICATE,
}
else
{
+ DBG2("Reading public key:");
if (file)
{
public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
{"crl", 'u', 1, "CRL distribution point URI to include"},
{"ocsp", 'o', 1, "OCSP AuthorityInfoAccess URI to include"},
{"digest", 'g', 1, "digest for signature creation, default: sha1"},
+ {"debug", 'v', 1, "set debug level, default: 1"},
{"options", '+', 1, "read command line options from file"},
}
});
{
case 'h':
return command_usage(NULL);
+ case 'v':
+ dbg_level = atoi(optarg);
+ continue;
case 't':
if (streq(optarg, "rsa-priv"))
{
{"help", 'h', 0, "show usage information"},
{"in", 'i', 1, "input file, default: stdin"},
{"type", 't', 1, "type of key, default: rsa-priv"},
+ {"debug", 'v', 1, "set debug level, default: 1"},
}
});
}
{
case 'h':
return command_usage(NULL);
+ case 'v':
+ dbg_level = atoi(optarg);
+ continue;
case 't':
if (streq(optarg, "rsa"))
{
{"in", 'i', 1, "input file, default: stdin"},
{"type", 't', 1, "type of credential, default: rsa"},
{"outform", 'f', 1, "encoding of extracted public key"},
+ {"debug", 'v', 1, "set debug level, default: 1"},
}
});
}
{
case 'h':
goto usage;
+ case 'v':
+ dbg_level = atoi(optarg);
+ continue;
case '+':
if (!options->from(options, optarg, &argc, &argv, optind))
{
{"ca", 'b', 0, "include CA basicConstraint, default: no"},
{"ocsp", 'o', 1, "OCSP AuthorityInfoAccess URI to include"},
{"digest", 'g', 1, "digest for signature creation, default: sha1"},
+ {"debug", 'v', 1, "set debug level, default: 1"},
{"options", '+', 1, "read command line options from file"},
}
});
{
case 'h':
return command_usage(NULL);
+ case 'v':
+ dbg_level = atoi(optarg);
+ continue;
case 'i':
file = optarg;
continue;
{"help", 'h', 0, "show usage information"},
{"in", 'i', 1, "x509 certifcate to verify, default: stdin"},
{"cacert", 'c', 1, "CA certificate, default: verify self signed"},
+ {"debug", 'v', 1, "set debug level, default: 1"},
}
});
}
#include "command.h"
#include "pki.h"
+#include <debug.h>
+
+/**
+ * Default debug level
+ */
+int dbg_level = 1;
+
+/**
+ * Logging to stderr with configurable debug level
+ */
+void dbg_pki(int level, char *fmt, ...)
+{
+ if (level <= dbg_level)
+ {
+ va_list args;
+
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ fprintf(stderr, "\n");
+ va_end(args);
+ }
+}
+
/**
* Convert a form string to a encoding type
*/
*/
int main(int argc, char *argv[])
{
+ dbg = dbg_pki;
+
atexit(library_deinit);
if (!library_init(NULL))
{
#include <credentials/keys/private_key.h>
/**
+ * Defines the settable debug level
+ */
+extern int dbg_level;
+
+/**
* Convert a form string to a encoding type
*/
bool get_form(char *form, key_encoding_type_t *type, bool pub);