#include <qsossl.h> int SSL_Handshake(SSLHandle* handle, int how)
The SSL_Handshake() function is used by a program to initiate the SSL handshake protocol. Both the client and the server program must call the SSL_Handshake verb in order to initiate the handshake processing.
struct SSLHandleStr { /* SSLHandleStr */ int fd; /* Socket descriptor */ int createFlags; /* SSL_Create flags value */ unsigned protocol; /* SSL protocol version */ unsigned timeout; /* Timeout value in seconds */ unsigned char cipherKind[3]; /* Current 2.0 cipher suite */ unsigned short int cipherSuite; /* Current 3.0 cipher suite */ unsigned short int* cipherSuiteList; /* List of cipher suites */ unsigned int cipherSuiteListLen; /* Number of entries in the cipher suites list */ unsigned char* peerCert; /* Peer certificate */ unsigned peerCertLen; /* Peer certificate length */ int peerCertValidateRc; /* Return code from validation of certficate */ int (*exitPgm)(struct SSLHandleStr* sslh); /* Authentication exit program called when a certificate is received during SSL handshake */ };
The fields within the SSLHandle structure as pointed to by handle are defined as follows:
int fd (input) | The socket descriptor of the connection for which
the SSL handshake protocol is to be performed. This field was initialized by a
prior SSL_Create() API. |
||||||||
int createFlags (input) | Whether or not the SSL protocol is to be used. If
the field specifies a value that does not include the SSL_ENCRYPT flag, then
this function will return success without performing the SSL handshake
protocol. This field was initialized by a prior SSL_Create() API. |
||||||||
unsigned int protocol (input/output) | The type of SSL handshake protocol to be
performed. The protocol(s) that are acceptable as the handshake protocol for
this job. The following values may be specified for protocol and are defined in
<qsossl.h>.SSL_VERSION_CURRENT 0 (TLS with SSL Version 3.0 and SSL Version 2.0 compatibility) SSL_VERSION_2 2 (SSL Version 2.0 only) SSL_VERSION_3 3 (SSL Version 3.0 only) TLS_VERSION_1 4 (TLS Version 1 only) TLSV1_SSLV3 5 (TLS Version 1 with SSL Version 3.0 compatibility)Upon return, this field will be set to reflect the protocol version actually negotiated. If the createFlags field specifies a value that does not include the SSL_ENCRYPT flag, then this field will be unchanged from its input value. |
||||||||
unsigned timeout (input) | The approximate number of seconds to wait for the
SSL handshake protocol to complete. A value of 0 indicates to wait forever for
the handshake to complete. |
||||||||
unsigned char cipherKind[3] (output) | The cipher kind (which is the SSL Version 2.0
cipher suite) negotiated by the handshake. |
||||||||
unsigned short int cipherSuite (output) | The cipher suite type negotiated by the
handshake. |
||||||||
unsigned short int* cipherSuiteList (input) | A pointer to a cipher specification list that is
to be used during the handshake negotiation for this SSL session. This list is
a string of concatenated cipher specification values. Each cipher specification
is an unsigned short integer value. Any value provided will override, for this
SSL session, the default cipher specification list provided by a previous
SSL_Init() API or SSL_Init_Application() API . The valid
cipher suites allowed are defined in <qsossl.h>. A value of NULL
indicates one of the following:
|
||||||||
unsigned int cipherSuiteListLen (input) | The number of cipher suite entries specified in
the list pointed to by the cipherSuiteList field. |
||||||||
unsigned char* peerCert (output) | The pointer to the certificate received from the
peer system. For a client, this is a pointer to the server's certificate. For a
server with client authentication enabled, this is a pointer to the client's
certificate. For a server without client authentication this pointer value
remains unchanged. |
||||||||
unsigned peerCertLen (output) | The length of the certificate pointed to by the
peerCert field. |
||||||||
int (*exitPgm)(SSLHandle* sslh) (input) | A pointer to a user supplied function that is
called whenever a certificate is received during handshake processing. The
exitPgm will be passed the pointer to the
handle, which could include the peer's certificate.
The exitPgm returns a nonzero value if the peer's certificate is
accepted. The return of a zero value by the exitPgm will cause the
handshake processing to fail. Users of this function do not need to provide an
exit program. The pointer should be a NULL value if there is not a
user-supplied exit program. The exit program should be written in a threadsafe
manner. |
||||||||
int how (input) | The type of SSL handshake to be performed. The
following values may be specified for handshake type and are defined in
<qsossl.h>.
|
Authorization of *R (allow access to the object) to the key ring file and its associated files is required.
The SSL_Handshake() API returns an integer. Possible values are:
Successful return
The certificate is bad.
The certificate's signature is not valid.
The certificate is bad.
A cipher suite that is not valid was specified.
A bad message authentication code was received.
Unable to allocate storage required for SSL processing.
SSL received a badly formatted message.
The peer system is not recognized.
SSL detected a bad state in the SSL session.
The certificate is not valid or was rejected by the exit program.
The validity time period of the certificate is expired.
The SSL session ended.
An error occurred in SSL processing; check the errno value.
No certificate is available for SSL processing.
No ciphers available or specified.
SSL_Init() was not previously called for this job.
The certificate is not signed by a trusted certificate authority.
Permission was denied to access object.
SSL is not available for use.
An unknown or unexpected error occurred during SSL processing.
i5/OS does not support the certificate's type.
i5/OS does not support the certificate's type.
When the SSL_Handshake() API fails with a return code of [SSL_ERROR_IO], errno can be set to:
Permission denied.
Descriptor not valid.
Resource busy.
A connection with a remote socket was reset by that socket.
Resource deadlock avoided.
Bad address.
The system detected an address that was not valid while attempting to access the handle parameter or one of the address fields in the handle parameter.
Interrupted function call.
Parameter not valid.
This error code indicates one of the following:
Operation already in progress.
An SSL_Handshake() API has already been previously successfully completed.
Input/output error.
There is not enough buffer space for the requested operation.
Requested operation requires a connection.
This error code indicates one of the following:
The specified descriptor does not reference a socket.
Broken pipe.
A remote host did not respond within the timeout period.
The protocol required to support the specified address family is not available at this time.
Unknown system state.
Any errno that can be returned by send() or recv() can be returned by this API. See Sockets APIs for a description of the errno values they return.
If an errno is returned that is not in this list, see Errno Values for UNIX-Type Functions for a description of the errno.
Message ID | Error Message Text |
---|---|
CPE3418 E | Possible APAR condition or hardware failure. |
CPF9872 E | Program or service program &1 in library &2 ended. Reason code &3. |
CPFA081 E | Unable to set return value or error code. |
Top | UNIX-Type APIs | APIs by category |