Added policyConstraints support to pki tool
This commit is contained in:
+1
-1
@@ -201,7 +201,7 @@ int command_usage(char *error)
|
|||||||
}
|
}
|
||||||
for (i = 0; cmds[active].options[i].name; i++)
|
for (i = 0; cmds[active].options[i].name; i++)
|
||||||
{
|
{
|
||||||
fprintf(out, " --%-12s (-%c) %s\n",
|
fprintf(out, " --%-15s (-%c) %s\n",
|
||||||
cmds[active].options[i].name, cmds[active].options[i].op,
|
cmds[active].options[i].name, cmds[active].options[i].op,
|
||||||
cmds[active].options[i].desc);
|
cmds[active].options[i].desc);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ static int issue()
|
|||||||
linked_list_t *san, *cdps, *ocsp, *permitted, *excluded, *policies, *mappings;
|
linked_list_t *san, *cdps, *ocsp, *permitted, *excluded, *policies, *mappings;
|
||||||
int lifetime = 1095;
|
int lifetime = 1095;
|
||||||
int pathlen = X509_NO_CONSTRAINT;
|
int pathlen = X509_NO_CONSTRAINT;
|
||||||
|
int inhibit_policy = X509_NO_CONSTRAINT, explicit_policy = X509_NO_CONSTRAINT;
|
||||||
chunk_t serial = chunk_empty;
|
chunk_t serial = chunk_empty;
|
||||||
chunk_t encoding = chunk_empty;
|
chunk_t encoding = chunk_empty;
|
||||||
time_t not_before, not_after;
|
time_t not_before, not_after;
|
||||||
@@ -200,6 +201,12 @@ static int issue()
|
|||||||
mappings->insert_last(mappings, mapping);
|
mappings->insert_last(mappings, mapping);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
case 'E':
|
||||||
|
explicit_policy = atoi(arg);
|
||||||
|
continue;
|
||||||
|
case 'H':
|
||||||
|
inhibit_policy = atoi(arg);
|
||||||
|
continue;
|
||||||
case 'e':
|
case 'e':
|
||||||
if (streq(arg, "serverAuth"))
|
if (streq(arg, "serverAuth"))
|
||||||
{
|
{
|
||||||
@@ -420,6 +427,8 @@ static int issue()
|
|||||||
BUILD_EXCLUDED_NAME_CONSTRAINTS, excluded,
|
BUILD_EXCLUDED_NAME_CONSTRAINTS, excluded,
|
||||||
BUILD_CERTIFICATE_POLICIES, policies,
|
BUILD_CERTIFICATE_POLICIES, policies,
|
||||||
BUILD_POLICY_MAPPINGS, mappings,
|
BUILD_POLICY_MAPPINGS, mappings,
|
||||||
|
BUILD_POLICY_CONSTRAINT_INHIBIT, inhibit_policy,
|
||||||
|
BUILD_POLICY_CONSTRAINT_EXPLICIT, explicit_policy,
|
||||||
BUILD_END);
|
BUILD_END);
|
||||||
if (!cert)
|
if (!cert)
|
||||||
{
|
{
|
||||||
@@ -489,6 +498,7 @@ static void __attribute__ ((constructor))reg()
|
|||||||
"[--nc-permitted name] [--nc-excluded name]",
|
"[--nc-permitted name] [--nc-excluded name]",
|
||||||
"[--cert-policy oid [--cps-uri uri] [--user-notice text] ]+",
|
"[--cert-policy oid [--cps-uri uri] [--user-notice text] ]+",
|
||||||
"[--policy-map issuer-oid:subject-oid]",
|
"[--policy-map issuer-oid:subject-oid]",
|
||||||
|
"[--policy-explicit len] [--policy-inhibit len] ",
|
||||||
"[--digest md5|sha1|sha224|sha256|sha384|sha512] [--outform der|pem]"},
|
"[--digest md5|sha1|sha224|sha256|sha384|sha512] [--outform der|pem]"},
|
||||||
{
|
{
|
||||||
{"help", 'h', 0, "show usage information"},
|
{"help", 'h', 0, "show usage information"},
|
||||||
@@ -508,7 +518,9 @@ static void __attribute__ ((constructor))reg()
|
|||||||
{"cert-policy", 'P', 1, "certificatePolicy OID to include"},
|
{"cert-policy", 'P', 1, "certificatePolicy OID to include"},
|
||||||
{"cps-uri", 'C', 1, "Certification Practice statement URI for certificatePolicy"},
|
{"cps-uri", 'C', 1, "Certification Practice statement URI for certificatePolicy"},
|
||||||
{"user-notice", 'U', 1, "user notice for certificatePolicy"},
|
{"user-notice", 'U', 1, "user notice for certificatePolicy"},
|
||||||
{"policy-map", 'M', 1, "policyMapping from issuer to subject OID"},
|
{"policy-mapping", 'M', 1, "policyMapping from issuer to subject OID"},
|
||||||
|
{"policy-explicit", 'E', 1, "requireExplicitPolicy constraint"},
|
||||||
|
{"policy-inhibit", 'H', 1, "inhibitPolicyMapping constraint"},
|
||||||
{"flag", 'e', 1, "include extendedKeyUsage flag"},
|
{"flag", 'e', 1, "include extendedKeyUsage flag"},
|
||||||
{"crl", 'u', 1, "CRL distribution point URI to include"},
|
{"crl", 'u', 1, "CRL distribution point URI to include"},
|
||||||
{"crlissuer", 'I', 1, "CRL Issuer for CRL at distribution point"},
|
{"crlissuer", 'I', 1, "CRL Issuer for CRL at distribution point"},
|
||||||
|
|||||||
@@ -258,6 +258,22 @@ static void print_x509(x509_t *x509)
|
|||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
|
||||||
|
if (x509->get_policyConstraint(x509, FALSE) != X509_NO_CONSTRAINT ||
|
||||||
|
x509->get_policyConstraint(x509, TRUE) != X509_NO_CONSTRAINT)
|
||||||
|
{
|
||||||
|
printf("PolicyConstraints:\n");
|
||||||
|
if (x509->get_policyConstraint(x509, FALSE) != X509_NO_CONSTRAINT)
|
||||||
|
{
|
||||||
|
printf(" requireExplicitPolicy: %d\n",
|
||||||
|
x509->get_policyConstraint(x509, FALSE));
|
||||||
|
}
|
||||||
|
if (x509->get_policyConstraint(x509, TRUE) != X509_NO_CONSTRAINT)
|
||||||
|
{
|
||||||
|
printf(" inhibitPolicyMapping: %d\n",
|
||||||
|
x509->get_policyConstraint(x509, TRUE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
chunk = x509->get_authKeyIdentifier(x509);
|
chunk = x509->get_authKeyIdentifier(x509);
|
||||||
if (chunk.ptr)
|
if (chunk.ptr)
|
||||||
{
|
{
|
||||||
|
|||||||
+15
-2
@@ -57,6 +57,7 @@ static int self()
|
|||||||
linked_list_t *san, *ocsp, *permitted, *excluded, *policies, *mappings;
|
linked_list_t *san, *ocsp, *permitted, *excluded, *policies, *mappings;
|
||||||
int lifetime = 1095;
|
int lifetime = 1095;
|
||||||
int pathlen = X509_NO_CONSTRAINT;
|
int pathlen = X509_NO_CONSTRAINT;
|
||||||
|
int inhibit_policy = X509_NO_CONSTRAINT, explicit_policy = X509_NO_CONSTRAINT;
|
||||||
chunk_t serial = chunk_empty;
|
chunk_t serial = chunk_empty;
|
||||||
chunk_t encoding = chunk_empty;
|
chunk_t encoding = chunk_empty;
|
||||||
time_t not_before, not_after;
|
time_t not_before, not_after;
|
||||||
@@ -193,6 +194,12 @@ static int self()
|
|||||||
mappings->insert_last(mappings, mapping);
|
mappings->insert_last(mappings, mapping);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
case 'E':
|
||||||
|
explicit_policy = atoi(arg);
|
||||||
|
continue;
|
||||||
|
case 'H':
|
||||||
|
inhibit_policy = atoi(arg);
|
||||||
|
continue;
|
||||||
case 'e':
|
case 'e':
|
||||||
if (streq(arg, "serverAuth"))
|
if (streq(arg, "serverAuth"))
|
||||||
{
|
{
|
||||||
@@ -304,7 +311,10 @@ static int self()
|
|||||||
BUILD_PERMITTED_NAME_CONSTRAINTS, permitted,
|
BUILD_PERMITTED_NAME_CONSTRAINTS, permitted,
|
||||||
BUILD_EXCLUDED_NAME_CONSTRAINTS, excluded,
|
BUILD_EXCLUDED_NAME_CONSTRAINTS, excluded,
|
||||||
BUILD_CERTIFICATE_POLICIES, policies,
|
BUILD_CERTIFICATE_POLICIES, policies,
|
||||||
BUILD_POLICY_MAPPINGS, mappings, BUILD_END);
|
BUILD_POLICY_MAPPINGS, mappings,
|
||||||
|
BUILD_POLICY_CONSTRAINT_EXPLICIT, explicit_policy,
|
||||||
|
BUILD_POLICY_CONSTRAINT_INHIBIT, inhibit_policy,
|
||||||
|
BUILD_END);
|
||||||
if (!cert)
|
if (!cert)
|
||||||
{
|
{
|
||||||
error = "generating certificate failed";
|
error = "generating certificate failed";
|
||||||
@@ -367,6 +377,7 @@ static void __attribute__ ((constructor))reg()
|
|||||||
"[--nc-permitted name] [--nc-excluded name]",
|
"[--nc-permitted name] [--nc-excluded name]",
|
||||||
"[--cert-policy oid [--cps-uri uri] [--user-notice text] ]+",
|
"[--cert-policy oid [--cps-uri uri] [--user-notice text] ]+",
|
||||||
"[--policy-map issuer-oid:subject-oid]",
|
"[--policy-map issuer-oid:subject-oid]",
|
||||||
|
"[--policy-explicit len] [--policy-inhibit len] ",
|
||||||
"[--digest md5|sha1|sha224|sha256|sha384|sha512] [--outform der|pem]"},
|
"[--digest md5|sha1|sha224|sha256|sha384|sha512] [--outform der|pem]"},
|
||||||
{
|
{
|
||||||
{"help", 'h', 0, "show usage information"},
|
{"help", 'h', 0, "show usage information"},
|
||||||
@@ -384,7 +395,9 @@ static void __attribute__ ((constructor))reg()
|
|||||||
{"cert-policy", 'P', 1, "certificatePolicy OID to include"},
|
{"cert-policy", 'P', 1, "certificatePolicy OID to include"},
|
||||||
{"cps-uri", 'C', 1, "Certification Practice statement URI for certificatePolicy"},
|
{"cps-uri", 'C', 1, "Certification Practice statement URI for certificatePolicy"},
|
||||||
{"user-notice", 'U', 1, "user notice for certificatePolicy"},
|
{"user-notice", 'U', 1, "user notice for certificatePolicy"},
|
||||||
{"policy-map", 'M', 1, "policyMapping from issuer to subject OID"},
|
{"policy-mapping", 'M', 1, "policyMapping from issuer to subject OID"},
|
||||||
|
{"policy-explicit", 'E', 1, "requireExplicitPolicy constraint"},
|
||||||
|
{"policy-inhibit", 'H', 1, "inhibitPolicyMapping constraint"},
|
||||||
{"flag", 'e', 1, "include extendedKeyUsage flag"},
|
{"flag", 'e', 1, "include extendedKeyUsage flag"},
|
||||||
{"ocsp", 'o', 1, "OCSP AuthorityInfoAccess URI to include"},
|
{"ocsp", 'o', 1, "OCSP AuthorityInfoAccess URI to include"},
|
||||||
{"digest", 'g', 1, "digest for signature creation, default: sha1"},
|
{"digest", 'g', 1, "digest for signature creation, default: sha1"},
|
||||||
|
|||||||
Reference in New Issue
Block a user