2016-05-18 02:18:30 +08:00
|
|
|
/*
|
2018-02-27 21:37:28 +08:00
|
|
|
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
2001-10-21 01:56:36 +08:00
|
|
|
*
|
2016-05-18 02:18:30 +08:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* 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
|
2001-10-21 01:56:36 +08:00
|
|
|
*/
|
2016-05-18 02:18:30 +08:00
|
|
|
|
2001-02-20 16:13:47 +08:00
|
|
|
#include <openssl/opensslconf.h>
|
|
|
|
|
2003-09-28 05:56:08 +08:00
|
|
|
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
|
2015-01-22 11:40:55 +08:00
|
|
|
# include <conio.h>
|
2003-09-28 05:56:08 +08:00
|
|
|
#endif
|
|
|
|
|
2008-12-22 22:05:42 +08:00
|
|
|
#if defined(OPENSSL_SYS_MSDOS) && !defined(_WIN32)
|
2015-01-22 11:40:55 +08:00
|
|
|
# define _kbhit kbhit
|
2003-09-28 05:56:08 +08:00
|
|
|
#endif
|
|
|
|
|
2016-02-03 07:47:42 +08:00
|
|
|
#define PORT "4433"
|
1998-12-21 18:52:47 +08:00
|
|
|
#define PROTOCOL "tcp"
|
|
|
|
|
2017-04-20 16:56:56 +08:00
|
|
|
typedef int (*do_server_cb)(int s, int stype, int prot, unsigned char *context);
|
2016-02-03 07:47:42 +08:00
|
|
|
int do_server(int *accept_sock, const char *host, const char *port,
|
2017-04-20 16:56:56 +08:00
|
|
|
int family, int type, int protocol,
|
2016-02-14 11:33:56 +08:00
|
|
|
do_server_cb cb,
|
|
|
|
unsigned char *context, int naccept);
|
1998-12-21 18:52:47 +08:00
|
|
|
#ifdef HEADER_X509_H
|
2015-01-13 06:29:26 +08:00
|
|
|
int verify_callback(int ok, X509_STORE_CTX *ctx);
|
1998-12-21 18:52:47 +08:00
|
|
|
#endif
|
|
|
|
#ifdef HEADER_SSL_H
|
|
|
|
int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
|
2012-04-12 00:53:11 +08:00
|
|
|
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
|
2015-01-22 11:40:55 +08:00
|
|
|
STACK_OF(X509) *chain, int build_chain);
|
2012-07-08 22:22:45 +08:00
|
|
|
int ssl_print_sigalgs(BIO *out, SSL *s);
|
2012-11-22 23:20:53 +08:00
|
|
|
int ssl_print_point_formats(BIO *out, SSL *s);
|
2016-11-09 22:51:06 +08:00
|
|
|
int ssl_print_groups(BIO *out, SSL *s, int noshared);
|
1998-12-21 18:52:47 +08:00
|
|
|
#endif
|
2012-09-08 21:59:51 +08:00
|
|
|
int ssl_print_tmp_key(BIO *out, SSL *s);
|
2016-02-03 07:47:42 +08:00
|
|
|
int init_client(int *sock, const char *host, const char *port,
|
2018-02-08 17:49:02 +08:00
|
|
|
const char *bindhost, const char *bindport,
|
2017-04-20 16:57:12 +08:00
|
|
|
int family, int type, int protocol);
|
1998-12-21 18:52:47 +08:00
|
|
|
int should_retry(int i);
|
|
|
|
|
2015-01-13 06:29:26 +08:00
|
|
|
long bio_dump_callback(BIO *bio, int cmd, const char *argp,
|
2015-01-22 11:40:55 +08:00
|
|
|
int argi, long argl, long ret);
|
1998-12-21 18:52:47 +08:00
|
|
|
|
|
|
|
#ifdef HEADER_SSL_H
|
2015-01-13 06:29:26 +08:00
|
|
|
void apps_ssl_info_callback(const SSL *s, int where, int ret);
|
2015-01-22 11:40:55 +08:00
|
|
|
void msg_cb(int write_p, int version, int content_type, const void *buf,
|
|
|
|
size_t len, SSL *ssl, void *arg);
|
2016-02-01 22:26:18 +08:00
|
|
|
void tlsext_cb(SSL *s, int client_server, int type, const unsigned char *data,
|
2015-01-22 11:40:55 +08:00
|
|
|
int len, void *arg);
|
1998-12-21 18:52:47 +08:00
|
|
|
#endif
|
2009-09-05 01:42:53 +08:00
|
|
|
|
2015-01-22 11:40:55 +08:00
|
|
|
int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
|
|
|
|
unsigned int *cookie_len);
|
2015-10-06 23:20:32 +08:00
|
|
|
int verify_cookie_callback(SSL *ssl, const unsigned char *cookie,
|
2015-01-22 11:40:55 +08:00
|
|
|
unsigned int cookie_len);
|
2012-06-29 22:24:42 +08:00
|
|
|
|
2018-02-26 10:39:11 +08:00
|
|
|
int generate_stateless_cookie_callback(SSL *ssl, unsigned char *cookie,
|
|
|
|
size_t *cookie_len);
|
|
|
|
int verify_stateless_cookie_callback(SSL *ssl, const unsigned char *cookie,
|
|
|
|
size_t cookie_len);
|
|
|
|
|
2012-06-29 22:24:42 +08:00
|
|
|
typedef struct ssl_excert_st SSL_EXCERT;
|
|
|
|
|
|
|
|
void ssl_ctx_set_excert(SSL_CTX *ctx, SSL_EXCERT *exc);
|
|
|
|
void ssl_excert_free(SSL_EXCERT *exc);
|
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 args_excert(int option, SSL_EXCERT **pexc);
|
|
|
|
int load_excert(SSL_EXCERT **pexc);
|
Suppress DANE TLSA reflection when verification fails
As documented both SSL_get0_dane_authority() and SSL_get0_dane_tlsa()
are expected to return a negative match depth and nothing else when
verification fails. However, this only happened when verification
failed during chain construction. Errors in verification of the
constructed chain did not have the intended effect on these functions.
This commit updates the functions to check for verify_result ==
X509_V_OK, and no longer erases any accumulated match information
when chain construction fails. Sophisticated developers can, with
care, use SSL_set_verify_result(ssl, X509_V_OK) to "peek" at TLSA
info even when verification fail. They must of course first check
and save the real error, and restore the original error as quickly
as possible. Hiding by default seems to be the safer interface.
Introduced X509_V_ERR_DANE_NO_MATCH code to signal failure to find
matching TLSA records. Previously reported via X509_V_ERR_CERT_UNTRUSTED.
This also changes the "-brief" output from s_client to include
verification results and TLSA match information.
Mentioned session resumption in code example in SSL_CTX_dane_enable(3).
Also mentioned that depths returned are relative to the verified chain
which is now available via SSL_get0_verified_chain(3).
Added a few more test-cases to danetest, that exercise the new
code.
Resolved thread safety issue in use of static buffer in
X509_verify_cert_error_string().
Fixed long-stating issue in apps/s_cb.c which always sets verify_error
to either X509_V_OK or "chain to long", code elsewhere (e.g.
s_time.c), seems to expect the actual error. [ The new chain
construction code is expected to correctly generate "chain
too long" errors, so at some point we need to drop the
work-arounds, once SSL_set_verify_depth() is also fixed to
propagate the depth to X509_STORE_CTX reliably. ]
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-08 08:07:57 +08:00
|
|
|
void print_verify_detail(SSL *s, BIO *bio);
|
2015-04-29 23:27:08 +08:00
|
|
|
void print_ssl_summary(SSL *s);
|
2012-11-17 22:42:22 +08:00
|
|
|
#ifdef HEADER_SSL_H
|
2016-02-14 13:17:59 +08:00
|
|
|
int config_ctx(SSL_CONF_CTX *cctx, STACK_OF(OPENSSL_STRING) *str, SSL_CTX *ctx);
|
2015-01-22 11:40:55 +08:00
|
|
|
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls,
|
|
|
|
int crl_download);
|
|
|
|
int ssl_load_stores(SSL_CTX *ctx, const char *vfyCApath,
|
|
|
|
const char *vfyCAfile, const char *chCApath,
|
|
|
|
const char *chCAfile, STACK_OF(X509_CRL) *crls,
|
|
|
|
int crl_download);
|
2015-04-29 23:27:08 +08:00
|
|
|
void ssl_ctx_security_debug(SSL_CTX *ctx, int verbose);
|
2017-02-02 02:14:27 +08:00
|
|
|
int set_keylog_file(SSL_CTX *ctx, const char *keylog_file);
|
2017-04-01 00:04:28 +08:00
|
|
|
void print_ca_names(BIO *bio, SSL *s);
|
2012-11-17 22:42:22 +08:00
|
|
|
#endif
|