📄 ssl.h
字号:
#endif/* compatibility */#define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg))#define SSL_get_app_data(s) (SSL_get_ex_data(s,0))#define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a))#define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0))#define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0))#define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg))/* The following are the possible values for ssl->state are are * used to indicate where we are up to in the SSL connection establishment. * The macros that follow are about the only things you should need to use * and even then, only when using non-blocking IO. * It can also be useful to work out where you were when the connection * failed */#define SSL_ST_CONNECT 0x1000#define SSL_ST_ACCEPT 0x2000#define SSL_ST_MASK 0x0FFF#define SSL_ST_INIT (SSL_ST_CONNECT|SSL_ST_ACCEPT)#define SSL_ST_BEFORE 0x4000#define SSL_ST_OK 0x03#define SSL_ST_RENEGOTIATE (0x04|SSL_ST_INIT)#define SSL_CB_LOOP 0x01#define SSL_CB_EXIT 0x02#define SSL_CB_READ 0x04#define SSL_CB_WRITE 0x08#define SSL_CB_ALERT 0x4000 /* used in callback */#define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ)#define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE)#define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP)#define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT)#define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP)#define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT)#define SSL_CB_HANDSHAKE_START 0x10#define SSL_CB_HANDSHAKE_DONE 0x20/* Is the SSL_connection established? */#define SSL_get_state(a) SSL_state(a)#define SSL_is_init_finished(a) (SSL_state(a) == SSL_ST_OK)#define SSL_in_init(a) (SSL_state(a)&SSL_ST_INIT)#define SSL_in_before(a) (SSL_state(a)&SSL_ST_BEFORE)#define SSL_in_connect_init(a) (SSL_state(a)&SSL_ST_CONNECT)#define SSL_in_accept_init(a) (SSL_state(a)&SSL_ST_ACCEPT)/* The following 2 states are kept in ssl->rstate when reads fail, * you should not need these */#define SSL_ST_READ_HEADER 0xF0#define SSL_ST_READ_BODY 0xF1#define SSL_ST_READ_DONE 0xF2/* Obtain latest Finished message * -- that we sent (SSL_get_finished) * -- that we expected from peer (SSL_get_peer_finished). * Returns length (0 == no Finished so far), copies up to 'count' bytes. */size_t SSL_get_finished(const SSL *s, void *buf, size_t count);size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);/* use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options * are 'ored' with SSL_VERIFY_PEER if they are desired */#define SSL_VERIFY_NONE 0x00#define SSL_VERIFY_PEER 0x01#define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02#define SSL_VERIFY_CLIENT_ONCE 0x04#define OpenSSL_add_ssl_algorithms() SSL_library_init()#define SSLeay_add_ssl_algorithms() SSL_library_init()/* this is for backward compatibility */#if 0 /* NEW_SSLEAY */#define SSL_CTX_set_default_verify(a,b,c) SSL_CTX_set_verify(a,b,c)#define SSL_set_pref_cipher(c,n) SSL_set_cipher_list(c,n)#define SSL_add_session(a,b) SSL_CTX_add_session((a),(b))#define SSL_remove_session(a,b) SSL_CTX_remove_session((a),(b))#define SSL_flush_sessions(a,b) SSL_CTX_flush_sessions((a),(b))#endif/* More backward compatibility */#define SSL_get_cipher(s) \ SSL_CIPHER_get_name(SSL_get_current_cipher(s))#define SSL_get_cipher_bits(s,np) \ SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np)#define SSL_get_cipher_version(s) \ SSL_CIPHER_get_version(SSL_get_current_cipher(s))#define SSL_get_cipher_name(s) \ SSL_CIPHER_get_name(SSL_get_current_cipher(s))#define SSL_get_time(a) SSL_SESSION_get_time(a)#define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b))#define SSL_get_timeout(a) SSL_SESSION_get_timeout(a)#define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b))#if 1 /*SSLEAY_MACROS*/#define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id)#define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id)#define PEM_read_SSL_SESSION(fp,x,cb,u) (SSL_SESSION *)PEM_ASN1_read( \ (char *(*)())d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,fp,(char **)x,cb,u)#define PEM_read_bio_SSL_SESSION(bp,x,cb,u) PEM_ASN1_read_bio_of(SSL_SESSION,d2i_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,cb,u)#define PEM_write_SSL_SESSION(fp,x) \ PEM_ASN1_write((int (*)())i2d_SSL_SESSION, \ PEM_STRING_SSL_SESSION,fp, (char *)x, NULL,NULL,0,NULL,NULL)#define PEM_write_bio_SSL_SESSION(bp,x) \ PEM_ASN1_write_bio_of(SSL_SESSION,i2d_SSL_SESSION,PEM_STRING_SSL_SESSION,bp,x,NULL,NULL,0,NULL,NULL)#endif#define SSL_AD_REASON_OFFSET 1000/* These alert types are for SSLv3 and TLSv1 */#define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY#define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE /* fatal */#define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC /* fatal */#define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED#define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW#define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE/* fatal */#define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE/* fatal */#define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE /* Not for TLS */#define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE#define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE#define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED#define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED#define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN#define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER /* fatal */#define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA /* fatal */#define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED /* fatal */#define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR /* fatal */#define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR#define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION/* fatal */#define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION /* fatal */#define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY/* fatal */#define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR /* fatal */#define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED#define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION#define SSL_ERROR_NONE 0#define SSL_ERROR_SSL 1#define SSL_ERROR_WANT_READ 2#define SSL_ERROR_WANT_WRITE 3#define SSL_ERROR_WANT_X509_LOOKUP 4#define SSL_ERROR_SYSCALL 5 /* look at error stack/return value/errno */#define SSL_ERROR_ZERO_RETURN 6#define SSL_ERROR_WANT_CONNECT 7#define SSL_ERROR_WANT_ACCEPT 8#define SSL_CTRL_NEED_TMP_RSA 1#define SSL_CTRL_SET_TMP_RSA 2#define SSL_CTRL_SET_TMP_DH 3#define SSL_CTRL_SET_TMP_ECDH 4#define SSL_CTRL_SET_TMP_RSA_CB 5#define SSL_CTRL_SET_TMP_DH_CB 6#define SSL_CTRL_SET_TMP_ECDH_CB 7#define SSL_CTRL_GET_SESSION_REUSED 8#define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9#define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10#define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11#define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12#define SSL_CTRL_GET_FLAGS 13#define SSL_CTRL_EXTRA_CHAIN_CERT 14#define SSL_CTRL_SET_MSG_CALLBACK 15#define SSL_CTRL_SET_MSG_CALLBACK_ARG 16/* only applies to datagram connections */#define SSL_CTRL_SET_MTU 17/* Stats */#define SSL_CTRL_SESS_NUMBER 20#define SSL_CTRL_SESS_CONNECT 21#define SSL_CTRL_SESS_CONNECT_GOOD 22#define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23#define SSL_CTRL_SESS_ACCEPT 24#define SSL_CTRL_SESS_ACCEPT_GOOD 25#define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26#define SSL_CTRL_SESS_HIT 27#define SSL_CTRL_SESS_CB_HIT 28#define SSL_CTRL_SESS_MISSES 29#define SSL_CTRL_SESS_TIMEOUTS 30#define SSL_CTRL_SESS_CACHE_FULL 31#define SSL_CTRL_OPTIONS 32#define SSL_CTRL_MODE 33#define SSL_CTRL_GET_READ_AHEAD 40#define SSL_CTRL_SET_READ_AHEAD 41#define SSL_CTRL_SET_SESS_CACHE_SIZE 42#define SSL_CTRL_GET_SESS_CACHE_SIZE 43#define SSL_CTRL_SET_SESS_CACHE_MODE 44#define SSL_CTRL_GET_SESS_CACHE_MODE 45#define SSL_CTRL_GET_MAX_CERT_LIST 50#define SSL_CTRL_SET_MAX_CERT_LIST 51#define SSL_session_reused(ssl) \ SSL_ctrl((ssl),SSL_CTRL_GET_SESSION_REUSED,0,NULL)#define SSL_num_renegotiations(ssl) \ SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL)#define SSL_clear_num_renegotiations(ssl) \ SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL)#define SSL_total_renegotiations(ssl) \ SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL)#define SSL_CTX_need_tmp_RSA(ctx) \ SSL_CTX_ctrl(ctx,SSL_CTRL_NEED_TMP_RSA,0,NULL)#define SSL_CTX_set_tmp_rsa(ctx,rsa) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)#define SSL_CTX_set_tmp_dh(ctx,dh) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh)#define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)#define SSL_need_tmp_RSA(ssl) \ SSL_ctrl(ssl,SSL_CTRL_NEED_TMP_RSA,0,NULL)#define SSL_set_tmp_rsa(ssl,rsa) \ SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA,0,(char *)rsa)#define SSL_set_tmp_dh(ssl,dh) \ SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh)#define SSL_set_tmp_ecdh(ssl,ecdh) \ SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh)#define SSL_CTX_add_extra_chain_cert(ctx,x509) \ SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509)#ifndef OPENSSL_NO_BIOBIO_METHOD *BIO_f_ssl(void);BIO *BIO_new_ssl(SSL_CTX *ctx,int client);BIO *BIO_new_ssl_connect(SSL_CTX *ctx);BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx);int BIO_ssl_copy_session_id(BIO *to,BIO *from);void BIO_ssl_shutdown(BIO *ssl_bio);#endifint SSL_CTX_set_cipher_list(SSL_CTX *,const char *str);SSL_CTX *SSL_CTX_new(SSL_METHOD *meth);void SSL_CTX_free(SSL_CTX *);long SSL_CTX_set_timeout(SSL_CTX *ctx,long t);long SSL_CTX_get_timeout(const SSL_CTX *ctx);X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *);int SSL_want(const SSL *s);int SSL_clear(SSL *s);void SSL_CTX_flush_sessions(SSL_CTX *ctx,long tm);SSL_CIPHER *SSL_get_current_cipher(const SSL *s);int SSL_CIPHER_get_bits(const SSL_CIPHER *c,int *alg_bits);char * SSL_CIPHER_get_version(const SSL_CIPHER *c);const char * SSL_CIPHER_get_name(const SSL_CIPHER *c);int SSL_get_fd(const SSL *s);int SSL_get_rfd(const SSL *s);int SSL_get_wfd(const SSL *s);const char * SSL_get_cipher_list(const SSL *s,int n);char * SSL_get_shared_ciphers(const SSL *s, char *buf, int len);int SSL_get_read_ahead(const SSL * s);int SSL_pending(const SSL *s);#ifndef OPENSSL_NO_SOCKint SSL_set_fd(SSL *s, int fd);int SSL_set_rfd(SSL *s, int fd);int SSL_set_wfd(SSL *s, int fd);#endif#ifndef OPENSSL_NO_BIOvoid SSL_set_bio(SSL *s, BIO *rbio,BIO *wbio);BIO * SSL_get_rbio(const SSL *s);BIO * SSL_get_wbio(const SSL *s);#endifint SSL_set_cipher_list(SSL *s, const char *str);void SSL_set_read_ahead(SSL *s, int yes);int SSL_get_verify_mode(const SSL *s);int SSL_get_verify_depth(const SSL *s);int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *);void SSL_set_verify(SSL *s, int mode, int (*callback)(int ok,X509_STORE_CTX *ctx));void SSL_set_verify_depth(SSL *s, int depth);#ifndef OPENSSL_NO_RSAint SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);#endifint SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, const unsigned char *d, long len);int SSL_use_certificate(SSL *ssl, X509 *x);int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len);#ifndef OPENSSL_NO_STDIOint SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type);int SSL_use_certificate_file(SSL *ssl, const char *file, int type);int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type);int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type);int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type);int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); /* PEM type */STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file);int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, const char *file);#ifndef OPENSSL_SYS_VMS#ifndef OPENSSL_SYS_MACINTOSH_CLASSIC /* XXXXX: Better scheme needed! [was: #ifndef MAC_OS_pre_X] */int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, const char *dir);#endif#endif#endifvoid SSL_load_error_strings(void );const char *SSL_state_string(const SSL *s);const char *SSL_rstate_string(const SSL *s);const char *SSL_state_string_long(const SSL *s);const char *SSL_rstate_string_long(const SSL *s);long SSL_SESSION_get_time(const SSL_SESSION *s);long SSL_SESSION_set_time(SSL_SESSION *s, long t);long SSL_SESSION_get_timeout(const SSL_SESSION *s);long SSL_SESSION_set_timeout(SSL_SESSION *s, long t);void SSL_copy_session_id(SSL *to,const SSL *from);SSL_SESSION *SSL_SESSION_new(void);unsigned long SSL_SESSION_hash(const SSL_SESSION *a);int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b);const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len);#ifndef OPENSSL_NO_FP_APIint SSL_SESSION_print_fp(FILE *fp,const SSL_SESSION *ses);#endif#ifndef OPENSSL_NO_BIOint SSL_SESSION_print(BIO *fp,const SSL_SESSION *ses);#endifvoid SSL_SESSION_free(SSL_SESSION *ses);int i2d_SSL_SESSION(SSL_SESSION *in,unsigned char **pp);int SSL_set_session(SSL *to, SSL_SESSION *session);int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c);int SSL_CTX_remove_session(SSL_CTX *,SSL_SESSION *c);int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB);int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -