![]() |
Home | Documentation |
SSL/TLS context and functions
updated by Robert van Engelen
|
This module defines functions to set the SSL/TLS context for HTTPS and WS-Security. More...
Macros | |
| #define | SOAP_SSL_DEFAULT (SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION | SOAP_TLSv1) |
| #define | SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE |
| #define | SOAP_SSL_NO_AUTHENTICATION |
| #define | SOAP_SSL_NO_DEFAULT_CA_PATH |
| #define | SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION |
| #define | SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION |
Functions | |
| *::soap_ssl_flags flag value to use RSA instead of DH *(automatically set when no DH parameter is specified) *` Do not initalized the SSL TLS library void | soap_ssl_noinit (void) |
| *Initialize the server side SSL TLS context int | soap_ssl_server_context (struct soap *soap, soap_ssl_flags flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *dhfile, const char *randfile, const char *sid) * @returns ` |
| *Initialize the client side SSL TLS context int | soap_ssl_client_context (struct soap *soap, soap_ssl_flags flags, const char *keyfile, const char *password, const char *cafile, const char *capath, const char *randfile) * @returns ` |
| *Enable SSL TLS CRLs int | soap_ssl_crl (struct soap *soap, const char *crlfile) * @returns ` |
| *Accept SSL TLS connection int | soap_ssl_accept (struct soap *soap) * @returns ` |
| *Setup function for OpenSSL versions prior to to set locks for multi threaded SSL TLS applications int | CRYPTO_thread_setup () |
| *Cleanup function for OpenSSL versions prior to int | CRYPTO_thread_cleanup () |
This module defines functions to set the SSL/TLS context for HTTPS and WS-Security.
| #define SOAP_SSL_ALLOW_EXPIRED_CERTIFICATE |
| #define SOAP_SSL_DEFAULT (SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION | SOAP_TLSv1) |
The SSL/TLS flags are:
| #define SOAP_SSL_NO_AUTHENTICATION |
This flag should be used sparingly such as for testing only.
| #define SOAP_SSL_NO_DEFAULT_CA_PATH |
| #define SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION |
This flag requires clients connected to the server to authenticate to the server. The soap_ssl_server_context must specify cafile and/or capath parameters with certificates (CA root and/or server certificates) to authenticate clients.
| #define SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION |
This flag requires connected servers to authenticate to the client. The soap_ssl_client_context must specify cafile and/or capath parameters with certificates (CA root and/or server certificates) to authenticate the server.
| *Cleanup function for OpenSSL versions prior to int CRYPTO_thread_cleanup | ( | ) |
| *Setup function for OpenSSL versions prior to to set locks for multi threaded SSL TLS applications int CRYPTO_thread_setup | ( | ) |
The CRYPTO_thread_setup() and CRYPTO_thread_setup cleanup functions should be defined in the source code of a multi-threaded SSL/TLS application as follows, requiring gsoap/plugin/threads.h:
| *Accept SSL TLS connection int soap_ssl_accept | ( | struct soap * | soap | ) |
This function should be called after calling ::soap_accept to perform the SSL/TLS handshake with a connected client. This function enforces HTTPS connections that are initialized with soap_ssl_server_context. Returns #SOAP_OK or a soap_status error code.
| *Initialize the client side SSL TLS context int soap_ssl_client_context | ( | struct soap * | soap, |
| soap_ssl_flags | flags, | ||
| const char * | keyfile, | ||
| const char * | password, | ||
| const char * | cafile, | ||
| const char * | capath, | ||
| const char * | randfile ) |
This function initializes the client-side SSL/TLS context of the OpenSSL, GNUTLS, or WolfSSL. The flags parameter initializes the context with a combination of ::soap_ssl_flags. The keyfile parameter when non-NULL is the client's private key PEM file, typically concatenated with its certificate in the PEM file. The client's key is normally NULL and should only be specified if the server requires client authentication. The password parameter when non-NULL is used to unlock the password-protected private key in the key file. The cafile parameter when non-NULL is used to authenticate servers and contains the CA certificates of the server or servers. Alternatively, a directory name capath can be specified to point to a directory with the certificate(s). The randfile parameter when non-NULL can be used to seed the PRNG using the specified file with random data. Returns #SOAP_OK or a soap_status error code.
All strings passed to this function must be persistent in memory until the SSL/TLS context is implicitly deleted when the soap context is deleted.
After soap_ssl_client_context initialization you can select a specific cipher list using OpenSSL function SSL_CTX_set_cipher_list(soap->ctx, "..."). When authentication requires the use of CRLs, you can use soap_ssl_crl to specify a CRL file and to use any CRLs provided with SSL/TLS handshakes.
All OpenSSL versions prior to 1.1.0 require mutex locks to be explicitly set up in your code for multi-threaded applications by calling CRYPTO_thread_setup() and CRYPTO_thread_cleanup().
Keychains can be used as an alternative to the cafile and capath parameters. See the gsoap/samples/ssl files ssl_setup.h, ssl_setup.c and ssl_setup.cpp for details.
| soap | soap context |
| flags | SSL/TLS context initialization flags |
| keyfile | private key file in PEM format or NULL |
| password | password to unlock the private key or NULL |
| cafile | file with certificates in PEM format or NULL |
| capath | directory to certificates |
| randfile | file to seed the PRNG or NULL |
| *Enable SSL TLS CRLs int soap_ssl_crl | ( | struct soap * | soap, |
| const char * | crlfile ) |
This function enables SSL/TLS CRL checking during the SSL/TLS handshake. The crlfile when non-NULL specifies a file with CRLs in PEM format. Returns #SOAP_OK or a soap_status error code.
| soap | soap context |
| crlfile | CRL file in PEM format or NULL |
| *::soap_ssl_flags flag value to use RSA instead of DH *(automatically set when no DH parameter is specified) *` Do not initalized the SSL TLS library void soap_ssl_noinit | ( | void | ) |
This flag can be used in combination with other SSL and TLS protocol flags, using | (bit-wise or).
This flag can be used in combination with other SSL and TLS protocol flags, using | (bit-wise or).
| *Initialize the server side SSL TLS context int soap_ssl_server_context | ( | struct soap * | soap, |
| soap_ssl_flags | flags, | ||
| const char * | keyfile, | ||
| const char * | password, | ||
| const char * | cafile, | ||
| const char * | capath, | ||
| const char * | dhfile, | ||
| const char * | randfile, | ||
| const char * | sid ) |
This function initializes the server-side SSL/TLS context of OpenSSL, GNUTLS, or WolfSSL. The flags parameter initializes the context with a combination of ::soap_ssl_flags. The keyfile parameter when non-NULL is the server's private key PEM file, typically concatenated with its certificate in the PEM file. The password parameter when non-NULL is used to unlock the password-protected private key in the key file. The cafile parameter when non-NULL is used to authenticate clients when the #SOAP_SSL_REQUIRE_CLIENT_AUTHENTICATION flag is used and contains the client or CA certificate(s). Alternatively, a directory name capath can be specified to point to a directory with the certificate(s). The dhfile parameter when non-NULL is a file with DH parameters to use DH instead of RSA. Alternatively, the dhfile parameter can be a numeric string value greater than 512 to let the engine generate the DH parameters, but beware this can take a while to execute. The randfile parameter when non-NULL can be used to seed the PRNG using the specified file with random data. The sid parameter when non-NULL is used for server-side session caching using a specified unique name per server. Returns #SOAP_OK or a soap_status error code.
All strings passed to this function except sid must be persistent in memory until the SSL/TLS context is implicitly deleted when the soap context is deleted.
All OpenSSL versions prior to 1.1.0 require mutex locks to be explicitly set up in your code for multi-threaded applications by calling CRYPTO_thread_setup() and CRYPTO_thread_cleanup().
After soap_ssl_server_context initialization you can select a specific cipher list using OpenSSL function SSL_CTX_set_cipher_list(soap->ctx, "..."). When client authentication is required with CRLs, you can use soap_ssl_crl to specify a CRL file and to use any CRLs provided with SSL/TLS handshakes.
| soap | soap context |
| flags | SSL/TLS context initialization flags |
| keyfile | private key file in PEM format or NULL |
| password | password to unlock the private key or NULL |
| cafile | file with certificates in PEM format or NULL |
| capath | directory to certificates |
| dhfile | file with DH parameters or numeric string value to generate DH parameters or NULL for RSA |
| randfile | file to seed the PRNG or NULL |
| sid | a unique server id for session caching or NULL |