mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-16 00:00:37 -04:00
pki --pkcs7 --verify shows prints the signing time, if available
This commit is contained in:
parent
d3d706f4fc
commit
9afbe59953
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#include "pki.h"
|
#include "pki.h"
|
||||||
|
|
||||||
|
#include <asn1/oid.h>
|
||||||
|
#include <asn1/asn1.h>
|
||||||
#include <credentials/containers/pkcs7.h>
|
#include <credentials/containers/pkcs7.h>
|
||||||
#include <credentials/sets/mem_cred.h>
|
#include <credentials/sets/mem_cred.h>
|
||||||
|
|
||||||
@ -71,10 +73,12 @@ static bool write_to_stream(FILE *stream, chunk_t data)
|
|||||||
static int verify(chunk_t chunk)
|
static int verify(chunk_t chunk)
|
||||||
{
|
{
|
||||||
container_t *container;
|
container_t *container;
|
||||||
|
pkcs7_t *pkcs7;
|
||||||
enumerator_t *enumerator;
|
enumerator_t *enumerator;
|
||||||
certificate_t *cert;
|
certificate_t *cert;
|
||||||
auth_cfg_t *auth;
|
auth_cfg_t *auth;
|
||||||
chunk_t data;
|
chunk_t data;
|
||||||
|
time_t t;
|
||||||
bool verified = FALSE;
|
bool verified = FALSE;
|
||||||
|
|
||||||
container = lib->creds->create(lib->creds, CRED_CONTAINER, CONTAINER_PKCS7,
|
container = lib->creds->create(lib->creds, CRED_CONTAINER, CONTAINER_PKCS7,
|
||||||
@ -92,6 +96,7 @@ static int verify(chunk_t chunk)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pkcs7 = (pkcs7_t*)container;
|
||||||
enumerator = container->create_signature_enumerator(container);
|
enumerator = container->create_signature_enumerator(container);
|
||||||
while (enumerator->enumerate(enumerator, &auth))
|
while (enumerator->enumerate(enumerator, &auth))
|
||||||
{
|
{
|
||||||
@ -99,7 +104,18 @@ static int verify(chunk_t chunk)
|
|||||||
cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
|
cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
|
||||||
if (cert)
|
if (cert)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "signed by '%Y'\n", cert->get_subject(cert));
|
fprintf(stderr, "signed by '%Y'", cert->get_subject(cert));
|
||||||
|
|
||||||
|
if (pkcs7->get_attribute(pkcs7, OID_PKCS9_SIGNING_TIME,
|
||||||
|
enumerator, &data))
|
||||||
|
{
|
||||||
|
t = asn1_to_time(&data, ASN1_UTCTIME);
|
||||||
|
if (t != UNDEFINED_TIME)
|
||||||
|
{
|
||||||
|
fprintf(stderr, " at %T", &t, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enumerator->destroy(enumerator);
|
enumerator->destroy(enumerator);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user