⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssl_ctx_set_default_passwd_cb.pod

📁 开源的ssl算法openssl,版本0.9.8H
💻 POD
字号:
=pod=head1 NAMESSL_CTX_set_default_passwd_cb, SSL_CTX_set_default_passwd_cb_userdata - set passwd callback for encrypted PEM file handling=head1 SYNOPSIS #include <openssl/ssl.h> void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); int pem_passwd_cb(char *buf, int size, int rwflag, void *userdata);=head1 DESCRIPTIONSSL_CTX_set_default_passwd_cb() sets the default password callback calledwhen loading/storing a PEM certificate with encryption.SSL_CTX_set_default_passwd_cb_userdata() sets a pointer to B<userdata> whichwill be provided to the password callback on invocation.The pem_passwd_cb(), which must be provided by the application, hands back thepassword to be used during decryption. On invocation a pointer to B<userdata>is provided. The pem_passwd_cb must write the password into the provided bufferB<buf> which is of size B<size>. The actual length of the password mustbe returned to the calling function. B<rwflag> indicates whether thecallback is used for reading/decryption (rwflag=0) or writing/encryption(rwflag=1).=head1 NOTESWhen loading or storing private keys, a password might be supplied toprotect the private key. The way this password can be supplied may dependon the application. If only one private key is handled, it can be practicalto have pem_passwd_cb() handle the password dialog interactively. If severalkeys have to be handled, it can be practical to ask for the password once,then keep it in memory and use it several times. In the last case, thepassword could be stored into the B<userdata> storage and thepem_passwd_cb() only returns the password already stored.When asking for the password interactively, pem_passwd_cb() can useB<rwflag> to check, whether an item shall be encrypted (rwflag=1).In this case the password dialog may ask for the same password twicefor comparison in order to catch typos, that would make decryptionimpossible.Other items in PEM formatting (certificates) can also be encrypted, it ishowever not usual, as certificate information is considered public.=head1 RETURN VALUESSSL_CTX_set_default_passwd_cb() and SSL_CTX_set_default_passwd_cb_userdata()do not provide diagnostic information.=head1 EXAMPLESThe following example returns the password provided as B<userdata> to thecalling function. The password is considered to be a '\0' terminatedstring. If the password does not fit into the buffer, the password istruncated. int pem_passwd_cb(char *buf, int size, int rwflag, void *password) {  strncpy(buf, (char *)(password), size);  buf[size - 1] = '\0';  return(strlen(buf)); }=head1 SEE ALSOL<ssl(3)|ssl(3)>,L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -