How can I set PEM password?
Hi, I use PEM file with password. In C language,It's provide a function callback to set the pem password (int tls_set(const char *cafile, const char *capath=NULL, const char *certfile=NULL, const char *keyfile=NULL, int (*pw_callback)(char *buf, int size, int rwflag, void *userdata)=NULL);)with libmosquitto. But I didn't find any function like that in paho.mqtt.python.Can it support that? If yes, how can I do? Thank you very much.
It doesn't seem to support it.
Per the docs at pypi under certfile, keyfile:
Note that if either of these files in encrypted and needs a password to decrypt it, Python will ask for the password at the command line. It is not currently possible to define a callback to provide the password.
Hi, it seems that the context which is used by loading the certificates, has an optional parameter for the password: client.py
context = ssl.SSLContext(tls_version)
# Configure context
if certfile is not None:
context.load_cert_chain(certfile, keyfile)
And in the SSLContext: https://docs.python.org/3/library/ssl.html#ssl.SSLContext.load_cert_chain New parameter password in version 3.3
def load_cert_chain(
self, certfile: StrPath, keyfile: Optional[StrPath] = ..., password: Optional[_PasswordType] = ...
) -> None: ...
I created a pull request #576