2016-05-18 02:18:30 +08:00
|
|
|
/*
|
2018-02-13 20:51:29 +08:00
|
|
|
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
1998-12-21 18:52:47 +08:00
|
|
|
*
|
2018-12-06 20:00:26 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:18:30 +08:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1998-12-21 18:52:47 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "apps.h"
|
2018-01-31 18:13:10 +08:00
|
|
|
#include "progs.h"
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/bio.h>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
#include <openssl/x509.h>
|
1999-11-26 08:27:07 +08:00
|
|
|
#include <openssl/x509v3.h>
|
1999-04-24 06:13:45 +08:00
|
|
|
#include <openssl/pem.h>
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2015-01-13 06:29:26 +08:00
|
|
|
static int cb(int ok, X509_STORE_CTX *ctx);
|
2016-08-05 05:52:22 +08:00
|
|
|
static int check(X509_STORE *ctx, const char *file,
|
2015-01-22 11:40:55 +08:00
|
|
|
STACK_OF(X509) *uchain, STACK_OF(X509) *tchain,
|
2018-10-26 21:34:08 +08:00
|
|
|
STACK_OF(X509_CRL) *crls, int show_chain,
|
|
|
|
unsigned char *sm2id, size_t sm2idlen);
|
2015-01-22 11:40:55 +08:00
|
|
|
static int v_verbose = 0, vflags = 0;
|
1998-12-21 18:52:47 +08:00
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
typedef enum OPTION_choice {
|
|
|
|
OPT_ERR = -1, OPT_EOF = 0, OPT_HELP,
|
2015-09-22 23:00:52 +08:00
|
|
|
OPT_ENGINE, OPT_CAPATH, OPT_CAFILE, OPT_NOCAPATH, OPT_NOCAFILE,
|
|
|
|
OPT_UNTRUSTED, OPT_TRUSTED, OPT_CRLFILE, OPT_CRL_DOWNLOAD, OPT_SHOW_CHAIN,
|
2017-06-06 23:35:43 +08:00
|
|
|
OPT_V_ENUM, OPT_NAMEOPT,
|
2018-10-26 21:34:08 +08:00
|
|
|
OPT_VERBOSE, OPT_SM2ID, OPT_SM2HEXID
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
} OPTION_CHOICE;
|
|
|
|
|
2016-03-13 21:07:50 +08:00
|
|
|
const OPTIONS verify_options[] = {
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
{OPT_HELP_STR, 1, '-', "Usage: %s [options] cert.pem...\n"},
|
|
|
|
{OPT_HELP_STR, 1, '-', "Valid options are:\n"},
|
|
|
|
{"help", OPT_HELP, '-', "Display this summary"},
|
2015-06-25 19:27:05 +08:00
|
|
|
{"verbose", OPT_VERBOSE, '-',
|
|
|
|
"Print extra information about the operations being performed."},
|
|
|
|
{"CApath", OPT_CAPATH, '/', "A directory of trusted certificates"},
|
|
|
|
{"CAfile", OPT_CAFILE, '<', "A file of trusted certificates"},
|
2015-09-22 23:00:52 +08:00
|
|
|
{"no-CAfile", OPT_NOCAFILE, '-',
|
|
|
|
"Do not load the default certificates file"},
|
|
|
|
{"no-CApath", OPT_NOCAPATH, '-',
|
|
|
|
"Do not load certificates from the default certificates directory"},
|
2015-06-25 19:27:05 +08:00
|
|
|
{"untrusted", OPT_UNTRUSTED, '<', "A file of untrusted certificates"},
|
2015-07-10 02:54:13 +08:00
|
|
|
{"trusted", OPT_TRUSTED, '<', "A file of trusted certificates"},
|
2015-06-25 19:27:05 +08:00
|
|
|
{"CRLfile", OPT_CRLFILE, '<',
|
|
|
|
"File containing one or more CRL's (in PEM format) to load"},
|
|
|
|
{"crl_download", OPT_CRL_DOWNLOAD, '-',
|
|
|
|
"Attempt to download CRL information for this certificate"},
|
|
|
|
{"show_chain", OPT_SHOW_CHAIN, '-',
|
|
|
|
"Display information about the certificate chain"},
|
2017-02-17 07:06:47 +08:00
|
|
|
{"nameopt", OPT_NAMEOPT, 's', "Various certificate name options"},
|
2015-05-16 01:50:38 +08:00
|
|
|
OPT_V_OPTIONS,
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
#ifndef OPENSSL_NO_ENGINE
|
|
|
|
{"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
|
2018-10-26 21:34:08 +08:00
|
|
|
#endif
|
|
|
|
#ifndef OPENSSL_NO_SM2
|
|
|
|
{"sm2-id", OPT_SM2ID, 's',
|
|
|
|
"Specify an ID string to verify an SM2 certificate"},
|
|
|
|
{"sm2-hex-id", OPT_SM2HEXID, 's',
|
|
|
|
"Specify a hex ID string to verify an SM2 certificate"},
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
#endif
|
|
|
|
{NULL}
|
|
|
|
};
|
2000-02-11 17:47:18 +08:00
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
int verify_main(int argc, char **argv)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
2016-09-29 05:39:18 +08:00
|
|
|
ENGINE *e = NULL;
|
2015-01-22 11:40:55 +08:00
|
|
|
STACK_OF(X509) *untrusted = NULL, *trusted = NULL;
|
|
|
|
STACK_OF(X509_CRL) *crls = NULL;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
X509_STORE *store = NULL;
|
2015-01-22 11:40:55 +08:00
|
|
|
X509_VERIFY_PARAM *vpm = NULL;
|
2016-08-05 05:52:22 +08:00
|
|
|
const char *prog, *CApath = NULL, *CAfile = NULL;
|
2015-09-22 23:00:52 +08:00
|
|
|
int noCApath = 0, noCAfile = 0;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
int vpmtouched = 0, crl_download = 0, show_chain = 0, i = 0, ret = 1;
|
|
|
|
OPTION_CHOICE o;
|
2018-10-26 21:34:08 +08:00
|
|
|
unsigned char *sm2_id = NULL;
|
|
|
|
size_t sm2_idlen = 0;
|
2019-03-13 18:04:05 +08:00
|
|
|
int sm2_free = 0;
|
1998-12-21 18:52:47 +08:00
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
if ((vpm = X509_VERIFY_PARAM_new()) == NULL)
|
2015-01-22 11:40:55 +08:00
|
|
|
goto end;
|
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
prog = opt_init(argc, argv, verify_options);
|
|
|
|
while ((o = opt_next()) != OPT_EOF) {
|
|
|
|
switch (o) {
|
|
|
|
case OPT_EOF:
|
|
|
|
case OPT_ERR:
|
|
|
|
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
|
|
|
|
goto end;
|
|
|
|
case OPT_HELP:
|
|
|
|
opt_help(verify_options);
|
|
|
|
BIO_printf(bio_err, "Recognized usages:\n");
|
|
|
|
for (i = 0; i < X509_PURPOSE_get_count(); i++) {
|
|
|
|
X509_PURPOSE *ptmp;
|
|
|
|
ptmp = X509_PURPOSE_get0(i);
|
|
|
|
BIO_printf(bio_err, "\t%-10s\t%s\n",
|
|
|
|
X509_PURPOSE_get0_sname(ptmp),
|
|
|
|
X509_PURPOSE_get0_name(ptmp));
|
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
BIO_printf(bio_err, "Recognized verify names:\n");
|
|
|
|
for (i = 0; i < X509_VERIFY_PARAM_get_count(); i++) {
|
|
|
|
const X509_VERIFY_PARAM *vptmp;
|
|
|
|
vptmp = X509_VERIFY_PARAM_get0(i);
|
|
|
|
BIO_printf(bio_err, "\t%-10s\n",
|
|
|
|
X509_VERIFY_PARAM_get0_name(vptmp));
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
ret = 0;
|
|
|
|
goto end;
|
|
|
|
case OPT_V_CASES:
|
|
|
|
if (!opt_verify(o, vpm))
|
2015-01-22 11:40:55 +08:00
|
|
|
goto end;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
vpmtouched++;
|
|
|
|
break;
|
|
|
|
case OPT_CAPATH:
|
|
|
|
CApath = opt_arg();
|
|
|
|
break;
|
|
|
|
case OPT_CAFILE:
|
|
|
|
CAfile = opt_arg();
|
|
|
|
break;
|
2015-09-22 23:00:52 +08:00
|
|
|
case OPT_NOCAPATH:
|
|
|
|
noCApath = 1;
|
|
|
|
break;
|
|
|
|
case OPT_NOCAFILE:
|
|
|
|
noCAfile = 1;
|
|
|
|
break;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
case OPT_UNTRUSTED:
|
2016-01-16 14:15:02 +08:00
|
|
|
/* Zero or more times */
|
2016-02-14 11:33:56 +08:00
|
|
|
if (!load_certs(opt_arg(), &untrusted, FORMAT_PEM, NULL,
|
2016-01-16 14:15:02 +08:00
|
|
|
"untrusted certificates"))
|
|
|
|
goto end;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
break;
|
|
|
|
case OPT_TRUSTED:
|
2016-01-16 14:15:02 +08:00
|
|
|
/* Zero or more times */
|
|
|
|
noCAfile = 1;
|
|
|
|
noCApath = 1;
|
2016-02-14 11:33:56 +08:00
|
|
|
if (!load_certs(opt_arg(), &trusted, FORMAT_PEM, NULL,
|
2016-01-16 14:15:02 +08:00
|
|
|
"trusted certificates"))
|
|
|
|
goto end;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
break;
|
|
|
|
case OPT_CRLFILE:
|
2016-01-16 14:15:02 +08:00
|
|
|
/* Zero or more times */
|
2016-02-14 11:33:56 +08:00
|
|
|
if (!load_crls(opt_arg(), &crls, FORMAT_PEM, NULL,
|
2016-01-16 14:15:02 +08:00
|
|
|
"other CRLs"))
|
|
|
|
goto end;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
break;
|
|
|
|
case OPT_CRL_DOWNLOAD:
|
|
|
|
crl_download = 1;
|
2015-01-22 11:40:55 +08:00
|
|
|
break;
|
2016-02-14 11:33:56 +08:00
|
|
|
case OPT_ENGINE:
|
2016-09-29 05:39:18 +08:00
|
|
|
if ((e = setup_engine(opt_arg(), 0)) == NULL) {
|
2016-02-14 11:33:56 +08:00
|
|
|
/* Failure message already displayed */
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
break;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
case OPT_SHOW_CHAIN:
|
|
|
|
show_chain = 1;
|
|
|
|
break;
|
2017-02-17 07:06:47 +08:00
|
|
|
case OPT_NAMEOPT:
|
2017-04-26 00:25:42 +08:00
|
|
|
if (!set_nameopt(opt_arg()))
|
2017-02-17 07:06:47 +08:00
|
|
|
goto end;
|
|
|
|
break;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
case OPT_VERBOSE:
|
|
|
|
v_verbose = 1;
|
|
|
|
break;
|
2018-10-26 21:34:08 +08:00
|
|
|
case OPT_SM2ID:
|
2019-06-04 09:32:58 +08:00
|
|
|
if (sm2_id != NULL) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"Use one of the options 'sm2-hex-id' or 'sm2-id' \n");
|
|
|
|
goto end;
|
|
|
|
}
|
2018-10-26 21:34:08 +08:00
|
|
|
sm2_id = (unsigned char *)opt_arg();
|
|
|
|
sm2_idlen = strlen((const char *)sm2_id);
|
|
|
|
break;
|
|
|
|
case OPT_SM2HEXID:
|
2019-06-04 09:32:58 +08:00
|
|
|
if (sm2_id != NULL) {
|
|
|
|
BIO_printf(bio_err,
|
|
|
|
"Use one of the options 'sm2-hex-id' or 'sm2-id' \n");
|
|
|
|
goto end;
|
|
|
|
}
|
2018-10-26 21:34:08 +08:00
|
|
|
/* try to parse the input as hex string first */
|
2019-03-13 18:04:05 +08:00
|
|
|
sm2_free = 1;
|
2018-10-26 21:34:08 +08:00
|
|
|
sm2_id = OPENSSL_hexstr2buf(opt_arg(), (long *)&sm2_idlen);
|
|
|
|
if (sm2_id == NULL) {
|
|
|
|
BIO_printf(bio_err, "Invalid hex string input\n");
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
break;
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
argc = opt_num_rest();
|
|
|
|
argv = opt_rest();
|
2016-01-16 14:15:02 +08:00
|
|
|
if (trusted != NULL && (CAfile || CApath)) {
|
2015-07-10 02:54:13 +08:00
|
|
|
BIO_printf(bio_err,
|
|
|
|
"%s: Cannot use -trusted with -CAfile or -CApath\n",
|
|
|
|
prog);
|
|
|
|
goto end;
|
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2015-09-22 23:00:52 +08:00
|
|
|
if ((store = setup_verify(CAfile, CApath, noCAfile, noCApath)) == NULL)
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
goto end;
|
|
|
|
X509_STORE_set_verify_cb(store, cb);
|
2000-10-27 05:07:28 +08:00
|
|
|
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
if (vpmtouched)
|
|
|
|
X509_STORE_set1_param(store, vpm);
|
2015-01-22 11:40:55 +08:00
|
|
|
|
|
|
|
ERR_clear_error();
|
|
|
|
|
|
|
|
if (crl_download)
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
store_setup_crl_download(store);
|
2015-01-22 11:40:55 +08:00
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
if (argc < 1) {
|
2018-10-26 21:34:08 +08:00
|
|
|
if (check(store, NULL, untrusted, trusted, crls, show_chain,
|
|
|
|
sm2_id, sm2_idlen) != 1)
|
2015-01-22 11:40:55 +08:00
|
|
|
ret = -1;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < argc; i++)
|
2016-02-14 11:33:56 +08:00
|
|
|
if (check(store, argv[i], untrusted, trusted, crls,
|
2018-10-26 21:34:08 +08:00
|
|
|
show_chain, sm2_id, sm2_idlen) != 1)
|
2015-01-22 11:40:55 +08:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2019-03-13 18:04:05 +08:00
|
|
|
if (sm2_free)
|
|
|
|
OPENSSL_free(sm2_id);
|
2015-05-01 05:33:59 +08:00
|
|
|
X509_VERIFY_PARAM_free(vpm);
|
|
|
|
X509_STORE_free(store);
|
2015-01-22 11:40:55 +08:00
|
|
|
sk_X509_pop_free(untrusted, X509_free);
|
|
|
|
sk_X509_pop_free(trusted, X509_free);
|
|
|
|
sk_X509_CRL_pop_free(crls, X509_CRL_free);
|
2016-09-29 05:39:18 +08:00
|
|
|
release_engine(e);
|
Big apps cleanup (option-parsing, etc)
This is merges the old "rsalz-monolith" branch over to master. The biggest
change is that option parsing switch from cascasding 'else if strcmp("-foo")'
to a utility routine and somethin akin to getopt. Also, an error in the
command line no longer prints the full summary; use -help (or --help :)
for that. There have been many other changes and code-cleanup, see
bullet list below.
Special thanks to Matt for the long and detailed code review.
TEMPORARY:
For now, comment out CRYPTO_mem_leaks() at end of main
Tickets closed:
RT3515: Use 3DES in pkcs12 if built with no-rc2
RT1766: s_client -reconnect and -starttls broke
RT2932: Catch write errors
RT2604: port should be 'unsigned short'
RT2983: total_bytes undeclared #ifdef RENEG
RT1523: Add -nocert to fix output in x509 app
RT3508: Remove unused variable introduced by b09eb24
RT3511: doc fix; req default serial is random
RT1325,2973: Add more extensions to c_rehash
RT2119,3407: Updated to dgst.pod
RT2379: Additional typo fix
RT2693: Extra include of string.h
RT2880: HFS is case-insensitive filenames
RT3246: req command prints version number wrong
Other changes; incompatibilities marked with *:
Add SCSV support
Add -misalign to speed command
Make dhparam, dsaparam, ecparam, x509 output C in proper style
Make some internal ocsp.c functions void
Only display cert usages with -help in verify
Use global bio_err, remove "BIO*err" parameter from functions
For filenames, - always means stdin (or stdout as appropriate)
Add aliases for -des/aes "wrap" ciphers.
*Remove support for IISSGC (server gated crypto)
*The undocumented OCSP -header flag is now "-header name=value"
*Documented the OCSP -header flag
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-04-25 03:26:15 +08:00
|
|
|
return (ret < 0 ? 2 : ret);
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2016-08-05 05:52:22 +08:00
|
|
|
static int check(X509_STORE *ctx, const char *file,
|
2015-01-22 11:40:55 +08:00
|
|
|
STACK_OF(X509) *uchain, STACK_OF(X509) *tchain,
|
2018-10-26 21:34:08 +08:00
|
|
|
STACK_OF(X509_CRL) *crls, int show_chain,
|
|
|
|
unsigned char *sm2id, size_t sm2idlen)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
|
|
|
X509 *x = NULL;
|
|
|
|
int i = 0, ret = 0;
|
|
|
|
X509_STORE_CTX *csc;
|
|
|
|
STACK_OF(X509) *chain = NULL;
|
2015-06-25 19:28:28 +08:00
|
|
|
int num_untrusted;
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2016-02-14 11:33:56 +08:00
|
|
|
x = load_cert(file, FORMAT_PEM, "certificate file");
|
2015-01-22 11:40:55 +08:00
|
|
|
if (x == NULL)
|
|
|
|
goto end;
|
|
|
|
|
2018-10-26 21:34:08 +08:00
|
|
|
if (sm2id != NULL) {
|
|
|
|
#ifndef OPENSSL_NO_SM2
|
2019-04-01 09:21:53 +08:00
|
|
|
ASN1_OCTET_STRING *v;
|
2018-10-26 21:34:08 +08:00
|
|
|
|
2019-04-01 09:21:53 +08:00
|
|
|
v = ASN1_OCTET_STRING_new();
|
|
|
|
if (v == NULL) {
|
|
|
|
BIO_printf(bio_err, "error: SM2 ID allocation failed\n");
|
|
|
|
goto end;
|
|
|
|
}
|
2018-10-26 21:34:08 +08:00
|
|
|
|
2019-04-01 09:21:53 +08:00
|
|
|
if (!ASN1_OCTET_STRING_set(v, sm2id, sm2idlen)) {
|
|
|
|
BIO_printf(bio_err, "error: setting SM2 ID failed\n");
|
|
|
|
ASN1_OCTET_STRING_free(v);
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
X509_set0_sm2_id(x, v);
|
2018-10-26 21:34:08 +08:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
csc = X509_STORE_CTX_new();
|
|
|
|
if (csc == NULL) {
|
2019-04-01 09:21:53 +08:00
|
|
|
BIO_printf(bio_err, "error %s: X.509 store context allocation failed\n",
|
|
|
|
(file == NULL) ? "stdin" : file);
|
2015-01-22 11:40:55 +08:00
|
|
|
goto end;
|
|
|
|
}
|
2016-06-19 16:55:43 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
X509_STORE_set_flags(ctx, vflags);
|
|
|
|
if (!X509_STORE_CTX_init(csc, ctx, x, uchain)) {
|
2017-11-03 23:18:59 +08:00
|
|
|
X509_STORE_CTX_free(csc);
|
2019-04-01 09:21:53 +08:00
|
|
|
BIO_printf(bio_err,
|
|
|
|
"error %s: X.509 store context initialization failed\n",
|
|
|
|
(file == NULL) ? "stdin" : file);
|
2015-01-22 11:40:55 +08:00
|
|
|
goto end;
|
|
|
|
}
|
2017-06-13 01:24:02 +08:00
|
|
|
if (tchain != NULL)
|
2016-04-15 11:59:26 +08:00
|
|
|
X509_STORE_CTX_set0_trusted_stack(csc, tchain);
|
2017-06-13 01:24:02 +08:00
|
|
|
if (crls != NULL)
|
2015-01-22 11:40:55 +08:00
|
|
|
X509_STORE_CTX_set0_crls(csc, crls);
|
|
|
|
i = X509_verify_cert(csc);
|
2016-01-14 06:08:03 +08:00
|
|
|
if (i > 0 && X509_STORE_CTX_get_error(csc) == X509_V_OK) {
|
2019-04-01 09:21:53 +08:00
|
|
|
BIO_printf(bio_out, "%s: OK\n", (file == NULL) ? "stdin" : file);
|
2015-08-02 09:45:44 +08:00
|
|
|
ret = 1;
|
2016-01-02 07:45:29 +08:00
|
|
|
if (show_chain) {
|
|
|
|
int j;
|
2015-08-02 23:04:27 +08:00
|
|
|
|
2016-01-02 07:45:29 +08:00
|
|
|
chain = X509_STORE_CTX_get1_chain(csc);
|
|
|
|
num_untrusted = X509_STORE_CTX_get_num_untrusted(csc);
|
2019-04-01 09:21:53 +08:00
|
|
|
BIO_printf(bio_out, "Chain:\n");
|
2016-01-02 07:45:29 +08:00
|
|
|
for (j = 0; j < sk_X509_num(chain); j++) {
|
|
|
|
X509 *cert = sk_X509_value(chain, j);
|
2019-04-01 09:21:53 +08:00
|
|
|
BIO_printf(bio_out, "depth=%d: ", j);
|
2016-01-02 07:45:29 +08:00
|
|
|
X509_NAME_print_ex_fp(stdout,
|
|
|
|
X509_get_subject_name(cert),
|
2017-04-26 00:25:42 +08:00
|
|
|
0, get_nameopt());
|
2016-01-02 07:45:29 +08:00
|
|
|
if (j < num_untrusted)
|
2019-04-01 09:21:53 +08:00
|
|
|
BIO_printf(bio_out, " (untrusted)");
|
|
|
|
BIO_printf(bio_out, "\n");
|
2016-01-02 07:45:29 +08:00
|
|
|
}
|
|
|
|
sk_X509_pop_free(chain, X509_free);
|
|
|
|
}
|
|
|
|
} else {
|
2019-04-01 09:21:53 +08:00
|
|
|
BIO_printf(bio_err,
|
|
|
|
"error %s: verification failed\n",
|
|
|
|
(file == NULL) ? "stdin" : file);
|
2015-06-25 19:28:28 +08:00
|
|
|
}
|
2015-01-22 11:40:55 +08:00
|
|
|
X509_STORE_CTX_free(csc);
|
|
|
|
|
|
|
|
end:
|
2015-08-02 09:45:44 +08:00
|
|
|
if (i <= 0)
|
2016-01-02 07:45:29 +08:00
|
|
|
ERR_print_errors(bio_err);
|
2015-05-01 05:33:59 +08:00
|
|
|
X509_free(x);
|
2015-01-22 11:40:55 +08:00
|
|
|
|
2015-08-02 09:45:44 +08:00
|
|
|
return ret;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
1998-12-21 18:52:47 +08:00
|
|
|
|
2015-01-13 06:29:26 +08:00
|
|
|
static int cb(int ok, X509_STORE_CTX *ctx)
|
2015-01-22 11:40:55 +08:00
|
|
|
{
|
|
|
|
int cert_error = X509_STORE_CTX_get_error(ctx);
|
|
|
|
X509 *current_cert = X509_STORE_CTX_get_current_cert(ctx);
|
|
|
|
|
|
|
|
if (!ok) {
|
2017-06-13 01:24:02 +08:00
|
|
|
if (current_cert != NULL) {
|
2015-04-29 23:27:08 +08:00
|
|
|
X509_NAME_print_ex(bio_err,
|
|
|
|
X509_get_subject_name(current_cert),
|
2017-04-26 00:25:42 +08:00
|
|
|
0, get_nameopt());
|
2015-04-29 23:27:08 +08:00
|
|
|
BIO_printf(bio_err, "\n");
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|
2016-01-02 07:45:29 +08:00
|
|
|
BIO_printf(bio_err, "%serror %d at %d depth lookup: %s\n",
|
|
|
|
X509_STORE_CTX_get0_parent_ctx(ctx) ? "[CRL path] " : "",
|
2015-01-22 11:40:55 +08:00
|
|
|
cert_error,
|
|
|
|
X509_STORE_CTX_get_error_depth(ctx),
|
|
|
|
X509_verify_cert_error_string(cert_error));
|
2019-01-17 04:54:48 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Pretend that some errors are ok, so they don't stop further
|
|
|
|
* processing of the certificate chain. Setting ok = 1 does this.
|
|
|
|
* After X509_verify_cert() is done, we verify that there were
|
|
|
|
* no actual errors, even if the returned value was positive.
|
|
|
|
*/
|
2015-01-22 11:40:55 +08:00
|
|
|
switch (cert_error) {
|
|
|
|
case X509_V_ERR_NO_EXPLICIT_POLICY:
|
2015-04-29 23:27:08 +08:00
|
|
|
policies_print(ctx);
|
2017-05-11 22:21:37 +08:00
|
|
|
/* fall thru */
|
2015-01-22 11:40:55 +08:00
|
|
|
case X509_V_ERR_CERT_HAS_EXPIRED:
|
2019-01-17 04:54:48 +08:00
|
|
|
/* Continue even if the leaf is a self signed cert */
|
2015-01-22 11:40:55 +08:00
|
|
|
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
|
|
|
|
/* Continue after extension errors too */
|
|
|
|
case X509_V_ERR_INVALID_CA:
|
|
|
|
case X509_V_ERR_INVALID_NON_CA:
|
|
|
|
case X509_V_ERR_PATH_LENGTH_EXCEEDED:
|
|
|
|
case X509_V_ERR_INVALID_PURPOSE:
|
|
|
|
case X509_V_ERR_CRL_HAS_EXPIRED:
|
|
|
|
case X509_V_ERR_CRL_NOT_YET_VALID:
|
|
|
|
case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION:
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (cert_error == X509_V_OK && ok == 2)
|
2015-04-29 23:27:08 +08:00
|
|
|
policies_print(ctx);
|
2015-01-22 11:40:55 +08:00
|
|
|
if (!v_verbose)
|
|
|
|
ERR_clear_error();
|
2017-10-17 22:04:09 +08:00
|
|
|
return ok;
|
2015-01-22 11:40:55 +08:00
|
|
|
}
|