SSL_use_certificate_file
The SSL_use_certificate_file function loads the certificate for use with a Secure Sockets Layer (SSL) session.
Last updated
Changed for PUT00.
Format
LIBS := CSSL
#include <openssl/ssl.h>
int SSL_use_certificate_file(SSL *ssl,const char *file,int type) - ssl
- A pointer to a token returned on the SSL_new call.
- file
- A pointer to the name of the file that contains the certificate. The maximum length is 255 characters.
- type
- The file type, which is one of the following:
- SSL_FILETYPE_ASN1
- The file is in abstract syntax notation 1 (ASN.1) format.
- SSL_FILETYPE_PEM
- The file is in base64 privacy enhanced mail (PEM) format.
Normal return
Return code 1 indicates that the function was successful.
Error return
- A return code equal to 0 indicates an error. The following are
the most likely causes of errors:
- The certificate file does not exist or you do not have permission to read that file.
- The file type is not valid. The file type must be ASN.1 or PEM.
- If you loaded a private key file before issuing this function, the private key in that file does not match the corresponding public key in the certificate.
Programming considerations
- To use this function, you must include the library that is specified in the prototype in your makefile.
- When an SSL structure is first created using the SSL_new function, the structure inherits the certificate (if any exists) that is assigned to the context (CTX) structure that was used to create the SSL structure. The SSL_use_certificate_file function allows you to use a certificate other than the one assigned to the CTX structure.
- If you are assigning many SSL sessions to the same CTX structure and all sessions will use the same certificate, issue the SSL_CTX_use_certificate_file function once to assign the certificate to the CTX structure rather than issuing the SSL_use_certificate_file once for each SSL session.
- If you need to pass a chain of certificates rather than just one certificate, you must issue the SSL_CTX_use_certificate_chain_file function.
Examples
For sample SSL applications, see SSL examples.
Related information
See z/TPF Security for more SSL information.