gtpc1m5q | Transmission Control Protocol/Internet Protocol |
The SSL_CTX_use_PrivateKey_file function loads the private key
for use with Secure Sockets Layer (SSL) sessions using a specific context
(CTX) structure.
Format
#include <openssl/ssl.h>
int SSL_CTX_use_PrivateKey_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 private key.
- type
- The file type, which must be the following:
- 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 private key file does not exist or you do not have permission to read
that file.
- The private key file is not in PEM (base64 encoded) format.
- If the private key file is encrypted, the password is not correct or no
password was provided.
- If you loaded a certificate file before issuing this function, the public
key in that certificate does not match the corresponding private key in the
private key file.
Programming Considerations
- Before calling the SSL_CTX_use_PrivateKey_file function, you
must identify the password for the private key file by issuing the
SSL_CTX_set_default_passwd_cb_userdata function. Do this
only if the private key file has been encrypted.
- If you are assigning many SSL sessions to the same CTX structure and all
the sessions will use the same private key file, issue the
SSL_CTX_use_PrivateKey_file function once to assign the certificate
to the CTX structure rather than issuing the
SSL_CTX_use_PrivateKey_file function once for each SSL
session.
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