gtpc1m5p | Transmission Control Protocol/Internet Protocol |
The SSL_CTX_use_certificate_file function loads the certificate
for use with Secure Sockets Layer (SSL) sessions using a specific context
(CTX) structure.
Format
#include <openssl/ssl.h>
int SSL_CTX_use_certificate_file(SSL_CTX *ctx,const char *file,int type)
- ctx
- A pointer to a token returned on the SSL_CTX_new call or the
SSL_CTX_new_shared 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 PEM (base64 encoded) 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 abstract syntax
notation 1 (ASN.1) or PEM (base64 encoded).
- 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
- Each SSL structure that is created from this CTX structure using the
SSL_new function inherits the certificate of the CTX
structure. You can override the certificate used by an individual SSL
session by issuing the SSL_use_certificate_file function.
- If you are assigning many SSL sessions to the same CTX structure and all
the 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, go to http://www.ibm.com/tpf/pubs/tpfpubs.htm,
click SSL for the TPF 4.1 System: An Online User's
Guide, and click Examples from the left navigation
bar.
Related Information