gtpc1m6c | Transmission Control Protocol/Internet Protocol |
The SSL_use_certificate_file function loads the certificate for
use with a Secure Sockets Layer (SSL) session.
Format
#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 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 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
- 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, 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