提交 7880e143 编写于 作者: D Dr. Stephen Henson

Use accessors in X509_REQ_print().

Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 32f5c251
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
#include <openssl/bn.h> #include <openssl/bn.h>
#include <openssl/objects.h> #include <openssl/objects.h>
#include <openssl/x509.h> #include <openssl/x509.h>
#include "internal/x509_int.h"
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#ifndef OPENSSL_NO_RSA #ifndef OPENSSL_NO_RSA
# include <openssl/rsa.h> # include <openssl/rsa.h>
...@@ -93,9 +92,7 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, ...@@ -93,9 +92,7 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags,
{ {
long l; long l;
int i; int i;
X509_REQ_INFO *ri;
EVP_PKEY *pkey; EVP_PKEY *pkey;
STACK_OF(X509_ATTRIBUTE) *sk;
STACK_OF(X509_EXTENSION) *exts; STACK_OF(X509_EXTENSION) *exts;
char mlch = ' '; char mlch = ' ';
int nmindent = 0; int nmindent = 0;
...@@ -108,7 +105,6 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, ...@@ -108,7 +105,6 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags,
if (nmflags == X509_FLAG_COMPAT) if (nmflags == X509_FLAG_COMPAT)
nmindent = 16; nmindent = 16;
ri = &x->req_info;
if (!(cflag & X509_FLAG_NO_HEADER)) { if (!(cflag & X509_FLAG_NO_HEADER)) {
if (BIO_write(bp, "Certificate Request:\n", 21) <= 0) if (BIO_write(bp, "Certificate Request:\n", 21) <= 0)
goto err; goto err;
...@@ -123,7 +119,8 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, ...@@ -123,7 +119,8 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags,
if (!(cflag & X509_FLAG_NO_SUBJECT)) { if (!(cflag & X509_FLAG_NO_SUBJECT)) {
if (BIO_printf(bp, " Subject:%c", mlch) <= 0) if (BIO_printf(bp, " Subject:%c", mlch) <= 0)
goto err; goto err;
if (X509_NAME_print_ex(bp, ri->subject, nmindent, nmflags) < 0) if (X509_NAME_print_ex(bp, X509_REQ_get_subject_name(x),
nmindent, nmflags) < 0)
goto err; goto err;
if (BIO_write(bp, "\n", 1) <= 0) if (BIO_write(bp, "\n", 1) <= 0)
goto err; goto err;
...@@ -157,19 +154,18 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, ...@@ -157,19 +154,18 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags,
if (BIO_printf(bp, "%8sAttributes:\n", "") <= 0) if (BIO_printf(bp, "%8sAttributes:\n", "") <= 0)
goto err; goto err;
sk = x->req_info.attributes; if (X509_REQ_get_attr_count(x) == 0) {
if (sk_X509_ATTRIBUTE_num(sk) == 0) {
if (BIO_printf(bp, "%12sa0:00\n", "") <= 0) if (BIO_printf(bp, "%12sa0:00\n", "") <= 0)
goto err; goto err;
} else { } else {
for (i = 0; i < sk_X509_ATTRIBUTE_num(sk); i++) { for (i = 0; i < X509_REQ_get_attr_count(x); i++) {
ASN1_TYPE *at; ASN1_TYPE *at;
X509_ATTRIBUTE *a; X509_ATTRIBUTE *a;
ASN1_BIT_STRING *bs = NULL; ASN1_BIT_STRING *bs = NULL;
ASN1_OBJECT *aobj; ASN1_OBJECT *aobj;
int j, type = 0, count = 1, ii = 0; int j, type = 0, count = 1, ii = 0;
a = sk_X509_ATTRIBUTE_value(sk, i); a = X509_REQ_get_attr(x, i);
aobj = X509_ATTRIBUTE_get0_object(a); aobj = X509_ATTRIBUTE_get0_object(a);
if (X509_REQ_extension_nid(OBJ_obj2nid(aobj))) if (X509_REQ_extension_nid(OBJ_obj2nid(aobj)))
continue; continue;
...@@ -231,7 +227,10 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags, ...@@ -231,7 +227,10 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags,
} }
if (!(cflag & X509_FLAG_NO_SIGDUMP)) { if (!(cflag & X509_FLAG_NO_SIGDUMP)) {
if (!X509_signature_print(bp, &x->sig_alg, x->signature)) X509_ALGOR *sig_alg;
ASN1_BIT_STRING *sig;
X509_REQ_get0_signature(&sig, &sig_alg, x);
if (!X509_signature_print(bp, sig_alg, sig))
goto err; goto err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册