SSL_Strerror()--Retrieve SSL Runtime Error Message
Syntax
#include <qsossl.h>
char* SSL_Strerror(int sslreturnvalue,
SSLErrorMsg* serrmsgp);
Service Program Name: QSOSSLSR Default Public Authority: *USE
Threadsafe: Yes
The SSL_Strerror() function is used to retrieve an error message and associated text string which describes an SSL return value.
Parameters
- int sslreturnvalue (Input)
- The Return Value received from a SSL API.
- SSLErrorMsg* serrmsgp (Input)
- The pointer to a SSLErrorMsg structure. If no
SSLErrorMsg is provided, NULL must be entered.
SSLErrorMsg is a typedef for a buffer of type struct
SSLErrorMsgStr. In <qsossl.h>,
struct SSLErrorMsg is defined as the following:
struct SSLErrorMsgStr { /* SSLErrorMsgStr */ char messageID[7]; /* Message identifier */ char messageFile[20]; /* Qualified message file name */ };The fields within the SSLErrorMsg structure as pointed to by serrmsgp are defined as follows:
- char messageID[7] (output)
- The message identifier which defines the message associated with the input
sslreturnvalue.
- char messageFile[20] (output)
- The fully qualified message file name where the message associated with the messageID is stored. The first 10 characters specify the file name, and the second 10 characters specify the library.
Authorities
No authorization is required.
Return Value
The SSL_Strerror() API returns a pointer to the string. The null-terminated string is stored in the CCSID of the job. If the serrmsgp is provided, the SSLErrorMsg struct will be updated to reflect the message information corresponding to the string returned.
Error Conditions
If the sslreturnvalue is unrecognized, then an Unknown error message will be stored at the location pointed to by the return value. Other error conditions will be handled as described under Error Messages.
Error Messages
This API calls the Retrieve Message (QMHRTVM) API in order to perform its task. It inherits all error conditions from this function. If errors are encountered while using the Retrieve Message API, they will be reflected in the SSLErrorMsg fields (if provided) and any associated message replacement text will be stored at the location pointed to by the return value.
Related Information
- SSL_Perror()--Print SSL Error Message
- SSL_Create()--Enable SSL Support for the Specified
Socket Descriptor
- SSL_Destroy()--End SSL Support for the Specified SSL
Session
- SSL_Handshake()--Initiate the SSL Handshake
Protocol
- SSL_Init()--Initialize the Current Job for
SSL
- SSL_Init_Application()--Initialize the Current Job
for SSL Processing Based on the Application Identifier
- SSL_Read()--Receive Data from an SSL-Enabled Socket
Descriptor
- SSL_Write()--Write Data to an SSL-Enabled Socket Descriptor
Example
The following example shows how SSL_Strerror() is used.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <qsossl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
/* bufferLen is 250 bytes */
#define bufferLen 250
void main()
{
int bufferLen, on = 1, rc = 0, sd, sd2, addrlen = 0;
char buffer[bufferLen];
SSLInit sslinit;
SSLHandle* sslh;
struct sockaddr_in addr;
unsigned short int cipher[3] = {
SSL_RSA_WITH_RC4_128_MD5,
SSL_RSA_WITH_RC4_128_SHA,
SSL_RSA_EXPORT_WITH_RC4_40_MD5
};
/*************************************************/
/* memset sslinit structure to hex zeros and */
/* fill in values for the sslinit structure */
/*************************************************/
memset((char *)&SSL_Init, 0x00, sizeof(sslinit));
sslinit.keyringFileName = "/keyringfile.kyr";
sslinit.keyringPassword = NULL;
sslinit.cipherSuiteList = &cipher[0];
sslinit.cipherSuiteListLen = 3;
/*************************************************/
/* initialize SSL security call SSL_Init */
/*************************************************/
if ((rc = SSL_Init(&sslinit)) != 0)
{
printf("SSL_Init() failed with rc = %d %s \n"
"and errno = %d %s \n",rc,SSL_Strerror(rc, NULL),
errno,strerror(errno));
}
...
}
API introduced: V5R1