pki: Added ocsp-req and ocsp-rsp types to pki --print
This commit is contained in:
committed by
Tobias Brunner
parent
a0f672d3d1
commit
ec325b4c09
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015-2022 Andreas Steffen
|
||||
* Copyright (C) 2015-2023 Andreas Steffen
|
||||
* Copyright (C) 2010 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "credentials/certificates/x509.h"
|
||||
#include "credentials/certificates/crl.h"
|
||||
#include "credentials/certificates/ac.h"
|
||||
#include "credentials/certificates/ocsp_request.h"
|
||||
#include "credentials/certificates/ocsp_response.h"
|
||||
#include "credentials/certificates/pgp_certificate.h"
|
||||
|
||||
@@ -474,6 +475,36 @@ static void print_ac(private_certificate_printer_t *this, ac_t *ac)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print OCSP request specific information
|
||||
*/
|
||||
static void print_ocsp_request(private_certificate_printer_t *this,
|
||||
ocsp_request_t *ocsp_request)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
chunk_t nonce, issuerNameHash, issuerKeyHash, serialNumber;
|
||||
hash_algorithm_t hashAlgorithm;
|
||||
FILE *f = this->f;
|
||||
|
||||
nonce = ocsp_request->get_nonce(ocsp_request);
|
||||
fprintf(f, " nonce: %#B\n", &nonce);
|
||||
|
||||
enumerator = ocsp_request->create_request_enumerator(ocsp_request);
|
||||
while (enumerator->enumerate(enumerator, &hashAlgorithm, &issuerNameHash,
|
||||
&issuerKeyHash, &serialNumber))
|
||||
{
|
||||
fprintf(f, " serial: %#B\n", &serialNumber);
|
||||
fprintf(f, " issuer: keyHash: %#B\n", &issuerKeyHash);
|
||||
fprintf(f, " nameHash: %#B\n", &issuerNameHash);
|
||||
if (hashAlgorithm != HASH_SHA1)
|
||||
{
|
||||
fprintf(f, " hashAlg: %#N\n",
|
||||
hash_algorithm_short_names, hashAlgorithm);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print OCSP response specific information
|
||||
*/
|
||||
@@ -576,7 +607,8 @@ METHOD(certificate_printer_t, print, void,
|
||||
{
|
||||
fprintf(f, " subject: \"%Y\"\n", subject);
|
||||
}
|
||||
if (type != CERT_TRUSTED_PUBKEY && type != CERT_GPG)
|
||||
if (type != CERT_TRUSTED_PUBKEY && type != CERT_GPG &&
|
||||
type != CERT_X509_OCSP_REQUEST)
|
||||
{
|
||||
fprintf(f, " issuer: \"%Y\"\n", cert->get_issuer(cert));
|
||||
}
|
||||
@@ -637,6 +669,9 @@ METHOD(certificate_printer_t, print, void,
|
||||
case CERT_X509_AC:
|
||||
print_ac(this, (ac_t*)cert);
|
||||
break;
|
||||
case CERT_X509_OCSP_REQUEST:
|
||||
print_ocsp_request(this, (ocsp_request_t*)cert);
|
||||
break;
|
||||
case CERT_X509_OCSP_RESPONSE:
|
||||
print_ocsp_response(this, (ocsp_response_t*)cert);
|
||||
break;
|
||||
@@ -694,6 +729,9 @@ METHOD(certificate_printer_t, print_caption, void,
|
||||
case CERT_X509_CRL:
|
||||
caption = "X.509 CRL";
|
||||
break;
|
||||
case CERT_X509_OCSP_REQUEST:
|
||||
caption = "OCSP Request";
|
||||
break;
|
||||
case CERT_X509_OCSP_RESPONSE:
|
||||
caption = "OCSP Response";
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user