SSL_CTX_use_PrivateKey_file function or SSL_CTX_check_private_key function asks for password in terminal for my private key. I would like to pass this password in some OpenSSL function, so one of these functions don't asks about it in terminal. My application will get password from command line or from dialog window.
The function you are looking for is:
void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb);
The callback function argument pem_password_cb
has the signature:
int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata);
buf
is the destination buffer for the passphrase. size
gives the size of the buffer. rwflag
indicates whether the passphrase is for a decryption (read) or encryption (write) operation.
*userdata
is arbitrary data the application can specify to be passed to the callback. You can set the userdata
via the function:
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u);
See the SSL_CTX_set_default_passwd_cb(3)
man page for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With