2016-05-17 18:18:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2001-10-20 17:56:36 +00:00
|
|
|
*
|
2016-05-17 18:18:30 +00: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-20 17:56:36 +00:00
|
|
|
*/
|
2016-05-17 18:18:30 +00:00
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#include <openssl/opensslconf.h>
|
|
|
|
|
2003-09-27 21:56:08 +00:00
|
|
|
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS)
|
2015-01-22 03:40:55 +00:00
|
|
|
# include <conio.h>
|
2003-09-27 21:56:08 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-22 14:05:42 +00:00
|
|
|
#if defined(OPENSSL_SYS_MSDOS) && !defined(_WIN32)
|
2015-01-22 03:40:55 +00:00
|
|
|
# define _kbhit kbhit
|
2003-09-27 21:56:08 +00:00
|
|
|
#endif
|
|
|
|
|
2001-02-20 08:13:47 +00:00
|
|
|
#if defined(OPENSSL_SYS_VMS) && !defined(FD_SET)
|
2015-01-22 03:40:55 +00:00
|
|
|
/*
|
|
|
|
* VAX C does not defined fd_set and friends, but it's actually quite simple
|
|
|
|
*/
|
|
|
|
/* These definitions are borrowed from SOCKETSHR. /Richard Levitte */
|
|
|
|
# define MAX_NOFILE 32
|
|
|
|
# define NBBY 8 /* number of bits in a byte */
|
1999-05-13 11:37:32 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
# ifndef FD_SETSIZE
|
|
|
|
# define FD_SETSIZE MAX_NOFILE
|
|
|
|
# endif /* FD_SETSIZE */
|
1999-05-13 11:37:32 +00:00
|
|
|
|
|
|
|
/* How many things we'll allow select to use. 0 if unlimited */
|
2015-01-22 03:40:55 +00:00
|
|
|
# define MAXSELFD MAX_NOFILE
|
|
|
|
typedef int fd_mask; /* int here! VMS prototypes int, not long */
|
|
|
|
# define NFDBITS (sizeof(fd_mask) * NBBY)/* bits per mask (power of 2!) */
|
|
|
|
# define NFDSHIFT 5 /* Shift based on above */
|
1999-05-13 11:37:32 +00:00
|
|
|
|
|
|
|
typedef fd_mask fd_set;
|
2015-01-22 03:40:55 +00:00
|
|
|
# define FD_SET(n, p) (*(p) |= (1 << ((n) % NFDBITS)))
|
|
|
|
# define FD_CLR(n, p) (*(p) &= ~(1 << ((n) % NFDBITS)))
|
|
|
|
# define FD_ISSET(n, p) (*(p) & (1 << ((n) % NFDBITS)))
|
2015-05-04 22:00:15 +00:00
|
|
|
# define FD_ZERO(p) memset((p), 0, sizeof(*(p)))
|
1999-05-13 11:37:32 +00:00
|
|
|
#endif
|
|
|
|
|
2016-02-02 23:47:42 +00:00
|
|
|
#define PORT "4433"
|
1998-12-21 10:52:47 +00:00
|
|
|
#define PROTOCOL "tcp"
|
|
|
|
|
2016-02-14 03:33:56 +00:00
|
|
|
typedef int (*do_server_cb)(int s, int stype, unsigned char *context);
|
2016-02-02 23:47:42 +00:00
|
|
|
int do_server(int *accept_sock, const char *host, const char *port,
|
|
|
|
int family, int type,
|
2016-02-14 03:33:56 +00:00
|
|
|
do_server_cb cb,
|
|
|
|
unsigned char *context, int naccept);
|
1998-12-21 10:52:47 +00:00
|
|
|
#ifdef HEADER_X509_H
|
2015-01-12 22:29:26 +00:00
|
|
|
int verify_callback(int ok, X509_STORE_CTX *ctx);
|
1998-12-21 10:52:47 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HEADER_SSL_H
|
|
|
|
int set_cert_stuff(SSL_CTX *ctx, char *cert_file, char *key_file);
|
2012-04-11 16:53:11 +00:00
|
|
|
int set_cert_key_stuff(SSL_CTX *ctx, X509 *cert, EVP_PKEY *key,
|
2015-01-22 03:40:55 +00:00
|
|
|
STACK_OF(X509) *chain, int build_chain);
|
2012-07-08 14:22:45 +00:00
|
|
|
int ssl_print_sigalgs(BIO *out, SSL *s);
|
2012-11-22 15:20:53 +00:00
|
|
|
int ssl_print_point_formats(BIO *out, SSL *s);
|
2012-09-12 23:14:28 +00:00
|
|
|
int ssl_print_curves(BIO *out, SSL *s, int noshared);
|
1998-12-21 10:52:47 +00:00
|
|
|
#endif
|
2012-09-08 13:59:51 +00:00
|
|
|
int ssl_print_tmp_key(BIO *out, SSL *s);
|
2016-02-02 23:47:42 +00:00
|
|
|
int init_client(int *sock, const char *host, const char *port,
|
|
|
|
int family, int type);
|
1998-12-21 10:52:47 +00:00
|
|
|
int should_retry(int i);
|
|
|
|
|
2015-01-12 22:29:26 +00:00
|
|
|
long bio_dump_callback(BIO *bio, int cmd, const char *argp,
|
2015-01-22 03:40:55 +00:00
|
|
|
int argi, long argl, long ret);
|
1998-12-21 10:52:47 +00:00
|
|
|
|
|
|
|
#ifdef HEADER_SSL_H
|
2015-01-12 22:29:26 +00:00
|
|
|
void apps_ssl_info_callback(const SSL *s, int where, int ret);
|
2015-01-22 03:40:55 +00: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 14:26:18 +00:00
|
|
|
void tlsext_cb(SSL *s, int client_server, int type, const unsigned char *data,
|
2015-01-22 03:40:55 +00:00
|
|
|
int len, void *arg);
|
1998-12-21 10:52:47 +00:00
|
|
|
#endif
|
2009-09-04 17:42:53 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
int generate_cookie_callback(SSL *ssl, unsigned char *cookie,
|
|
|
|
unsigned int *cookie_len);
|
2015-10-06 15:20:32 +00:00
|
|
|
int verify_cookie_callback(SSL *ssl, const unsigned char *cookie,
|
2015-01-22 03:40:55 +00:00
|
|
|
unsigned int cookie_len);
|
2012-06-29 14:24:42 +00: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-24 19:26:15 +00: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 00:07:57 +00:00
|
|
|
void print_verify_detail(SSL *s, BIO *bio);
|
2015-04-29 15:27:08 +00:00
|
|
|
void print_ssl_summary(SSL *s);
|
2012-11-17 14:42:22 +00:00
|
|
|
#ifdef HEADER_SSL_H
|
2016-02-14 05:17:59 +00:00
|
|
|
int config_ctx(SSL_CONF_CTX *cctx, STACK_OF(OPENSSL_STRING) *str, SSL_CTX *ctx);
|
2015-01-22 03:40:55 +00: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 15:27:08 +00:00
|
|
|
void ssl_ctx_security_debug(SSL_CTX *ctx, int verbose);
|
2012-11-17 14:42:22 +00:00
|
|
|
#endif
|