]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/x509/t_crl.c
2 * Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include "internal/cryptlib.h"
12 #include <openssl/buffer.h>
13 #include <openssl/bn.h>
14 #include <openssl/objects.h>
15 #include <openssl/x509.h>
16 #include <openssl/x509v3.h>
18 DEFINE_STACK_OF(X509_REVOKED
)
20 #ifndef OPENSSL_NO_STDIO
21 int X509_CRL_print_fp(FILE *fp
, X509_CRL
*x
)
26 if ((b
= BIO_new(BIO_s_file())) == NULL
) {
27 X509err(X509_F_X509_CRL_PRINT_FP
, ERR_R_BUF_LIB
);
30 BIO_set_fp(b
, fp
, BIO_NOCLOSE
);
31 ret
= X509_CRL_print(b
, x
);
37 int X509_CRL_print(BIO
*out
, X509_CRL
*x
)
39 return X509_CRL_print_ex(out
, x
, XN_FLAG_COMPAT
);
42 int X509_CRL_print_ex(BIO
*out
, X509_CRL
*x
, unsigned long nmflag
)
44 STACK_OF(X509_REVOKED
) *rev
;
46 const X509_ALGOR
*sig_alg
;
47 const ASN1_BIT_STRING
*sig
;
51 BIO_printf(out
, "Certificate Revocation List (CRL):\n");
52 l
= X509_CRL_get_version(x
);
54 BIO_printf(out
, "%8sVersion %ld (0x%lx)\n", "", l
+ 1, (unsigned long)l
);
56 BIO_printf(out
, "%8sVersion unknown (%ld)\n", "", l
);
57 X509_CRL_get0_signature(x
, &sig
, &sig_alg
);
59 X509_signature_print(out
, sig_alg
, NULL
);
60 BIO_printf(out
, "%8sIssuer: ", "");
61 X509_NAME_print_ex(out
, X509_CRL_get_issuer(x
), 0, nmflag
);
63 BIO_printf(out
, "%8sLast Update: ", "");
64 ASN1_TIME_print(out
, X509_CRL_get0_lastUpdate(x
));
65 BIO_printf(out
, "\n%8sNext Update: ", "");
66 if (X509_CRL_get0_nextUpdate(x
))
67 ASN1_TIME_print(out
, X509_CRL_get0_nextUpdate(x
));
69 BIO_printf(out
, "NONE");
70 BIO_printf(out
, "\n");
72 X509V3_extensions_print(out
, "CRL extensions",
73 X509_CRL_get0_extensions(x
), 0, 8);
75 rev
= X509_CRL_get_REVOKED(x
);
77 if (sk_X509_REVOKED_num(rev
) > 0)
78 BIO_printf(out
, "Revoked Certificates:\n");
80 BIO_printf(out
, "No Revoked Certificates.\n");
82 for (i
= 0; i
< sk_X509_REVOKED_num(rev
); i
++) {
83 r
= sk_X509_REVOKED_value(rev
, i
);
84 BIO_printf(out
, " Serial Number: ");
85 i2a_ASN1_INTEGER(out
, X509_REVOKED_get0_serialNumber(r
));
86 BIO_printf(out
, "\n Revocation Date: ");
87 ASN1_TIME_print(out
, X509_REVOKED_get0_revocationDate(r
));
88 BIO_printf(out
, "\n");
89 X509V3_extensions_print(out
, "CRL entry extensions",
90 X509_REVOKED_get0_extensions(r
), 0, 8);
92 X509_signature_print(out
, sig_alg
, sig
);