52 #include <sys/types.h>
53 #include <sys/socket.h>
54 #include <netinet/in.h>
55 #include <arpa/inet.h>
58 #include <openssl/crypto.h>
59 #include <openssl/x509.h>
60 #include <openssl/pem.h>
61 #include <openssl/ssl.h>
62 #include <openssl/err.h>
63 #include <openssl/engine.h>
67 #define EXCHANGE_VERSION "1.1.0"
68 #define PORT_NUMBER_DEFAULT (49917)
70 #define CHK_NULL(x) if ((x)==NULL) { sleep(1); exit (1); }
71 #define CHK_ERR(err,s) if ((err)==-1) { perror(s); sleep(1); exit(1); }
72 #define CHK_SSL(err) if ((err)==-1) { ERR_print_errors_fp(stderr); sleep(2); exit(2); }
79 const char *cert_file);
81 int load_private_key(
const char *engine_id, SSL_CTX *ctx,
const char *key_file);
84 int connect_client(
const char *engine_id,
const char *ca_path,
const char *chain_file,
85 const char *cert_file,
const char *key_file,
const char *cipher_list,
86 const char *ip_address, uint16_t port_number);
87 int connect_server(
const char *engine_id,
const char *ca_path,
const char *chain_file,
88 const char *cert_file,
const char *key_file,
89 const char *ip_address, uint16_t port_number);
93 int run_engine_cmds(
const char *engine_id,
int cmd,
char *buffer,
int len);
int setup_engine(const char *engine_id)
setup OpenSSL engine by engine ID
Definition: tlsutil.c:58
int configure_context(SSL_CTX *ctx, const char *ca_path, const char *chain_file, const char *cert_file)
Configures the SSL context for server or client using provided certificates, chain files...
Definition: tlsutil.c:136
int connect_server(const char *engine_id, const char *ca_path, const char *chain_file, const char *cert_file, const char *key_file, const char *ip_address, uint16_t port_number)
A complete procedure of connecting server using TLS-1.2 protocol over TCP/IP.
Definition: server-tls2.c:58
int run_engine_cmds(const char *engine_id, int cmd, char *buffer, int len)
Definition: tlsutil.c:403
int config_args_ssl_call(SSL_CTX *ctx, SSL_CONF_CTX *cctx)
A modification of the args_ssl_call() function from the openssl aps/s_cb.c file.
Definition: tlsutil.c:236
void cleanup_openssl(void)
Call OpenSSL standard cleanup methods.
Definition: tlsutil.c:329
SSL_CTX * create_context(uint32_t is_server)
Creates the SSL context for server or client.
Definition: tlsutil.c:100
int save_x509_certificate(X509 *x509, const char *cert_fname)
Definition: tlsutil.c:373
int verify_callback(int ok, X509_STORE_CTX *ctx)
A modification of the verify_callback() function from the openssl aps/s_cb.c file.
Definition: tlsutil.c:265
void init_openssl(void)
Calls OpenSSL standard initialize methods.
Definition: tlsutil.c:86
int save_private_key(EVP_PKEY *pkey, const char *privkey_fname)
Definition: tlsutil.c:347
Function definitions used in OpenSSL ENGINE.
int load_private_key(const char *engine_id, SSL_CTX *ctx, const char *key_file)
setup OpenSSL engine by engine ID
Definition: tlsutil.c:187
int connect_client(const char *engine_id, const char *ca_path, const char *chain_file, const char *cert_file, const char *key_file, const char *cipher_list, const char *ip_address, uint16_t port_number)
A complete procedure of connecting client using TLS-1.2 protocol over TCP/IP.
Definition: client-tls2.c:62