|
The twApi_LoadCACert() function has a type argument that is NOT used. If you have used it, be aware that it is ignored at runtime.
|
|
Although you may want to enable self-signed certificates for development purposes, it is a security best practice to disable self-signed certificates and set up the proper certificates before putting your application into production.
Enabling self-signed certificates using twApi_setSelfSignedOk() does not add a certificate to the certificate chain used for validation. Rather, it accepts self-signed certificate notification codes from OpenSSL.
|
Partial wildcards in the CN field of the host certificate are not currently supported in TLS host name validation. The host certificate must match the destination host name exactly. For example, a host certificate with CN=platform.domain.com can be validated, but CN=*.domain.com cannot. If your host is using certificates with wildcards, host name validation must be disabled. |
Item | Description |
---|---|
TW_SSL_CTX | The SSL context structure as defined by the implementation. |
TW_SSL | The SSL session structure as defined by the implementation. |
TW_SSL_SESSION_ID_SIZE | The SSL session structure as defined by the implementation. |
TW_SSL_SESSION_ID_SIZE | The size of an SSL session ID as defined by the implementation. This ID is used for session resumption. |
TW_GET_CERT_SIZE | Returns the maximum number of certificates allowed by the implementation. |
TW_GET_CA_CERT_SIZE | Returns the maximum number of CA certificates allowed by the implementation. |
TW_NEW_SSL_CTX | Creates and initializes new instance of an SSL_CTX. |
TW_NEW_SSL_CLIENT(a,b,c,d) | Creates and initializes a new instance of an SSL structure within the provided SSL_CTX. Parameters: • a — pointer to a TW_SSL_CTX structure. • b — a TW_SOCKET_TYPE value that is the descriptor of the socket to be used. The underlying socket should not be opened before calling this function. • c — session id. The session ID if session resumption is being used. The SDK does not use session resumption and sets this to NULL. • d — size of the session ID that was passed in. |
TW_HANDSHAKE_SUCCEEDED | Returns a Boolean (char) value, TRUE if the SSL handshake succeeded and data can be securely exchanged, FALSE if otherwise. |
TW_SSL_FREE(a) | Close any socket and free up any memory associated with an SSL session. Parameter: • a — pointer to the TW_SSL structure to free. |
TW_SSL_CTX_FREE(a) | Free up any memory associated with an SSL context. Parameter: • a — pointer to the TW_SSL_CTX structure to free. |
TW_SSL_WRITE(a,b,c) | Writes data to the secure connection. Parameters: • a — pointer to the TW_SSL structure to write to. • b — pointer to the buffer containing the data to write. • c — the amount of data to write. This result of this macro should contain the number of bytes sent, or a negative number if an error occurred. |
TW_SSL_READ(a, b, c, d) | Reads data from the secure connection. Parameters: • a — pointer to the TW_SSL structure to read from. • b — pointer to the buffer that the data should be placed in. • c — the amount of data to read. • d — the number of milliseconds to wait while trying to read the desired amount of data. This result of this macro should contain the number of bytes read, or a negative number if an error occurred. |
TW_USE_CERT_FILE(a,b,c) | Loads an X509 certificate in PEM or DER format from the file specified. Parameters: • a — pointer to the TW_SSL_CTX structure load the certificate into. • b — name of the file containing the certificate. • c — a password to access the certificate (if required). |
TW_USE_KEY_FILE(a,b,c,d) | Loads an encrypted key in PEM or DER format from the file specified. Parameters: • a — pointer to the TW_SSL_CTX structure to read from • b — name of the file containing the key • c — the type of key • d — a password to access the key. |
TW_USE_CERT_CHAIN_FILE(a,b,c) | Loads a certificate chain in PEM or DER format from the file specified. Parameters: • a — pointer to the TW_SSL_CTX structure load the certificate into. • b — name of the file containing the certificate chain. • c — a password to access the certificate (if required). |
TW_SET_CLIENT_CA_LIST(a,b) | Sets the list of supported CAs from the file specified. Parameters: • a — pointer to the TW_SSL_CTX structure load the certificate into. • b — pointer to the CA list. |
TW_VALIDATE_CERT(TW_SSL * ssl, char selfSignedOk) | Inline function that validates the received certificate. Parameters: • ssl — pointer to the TW_SSL structure that has received the certificate • selfSignedOk — boolean, set to TRUE if self-signed certificates are allowed, FALSE if not. Default is FALSE. Returns zero if the certificate is valid, non-zero if not. |
TW_GET_X509_FIELD(TW_SSL * ssl, char field) | Inline function that gets the value of a field in the certificate. Parameters: • ssl — pointer to the TW_SSL structure that has received the certificate • field – char, the field to retrieve. Fields supported must be SUBJECT_CN, SUBJECT_O, SUBJECT_OU, ISSUER CN, ISSUER_O, ISSUER_OU Returns the value of the field, or NULL if the field is not found. |