Closed chusteven closed 1 year ago
ClientIdentity::new
expects a path to pkcs12 container. It is quite easy to create one from pem cert and key using openssl (I believe keytool should also work).
Thank you this helped! I'm on macOS and there were a couple things I had to do: 1/ Use the legacy option
openssl pkcs12 -export -legacy -in client-cert.pem \
-inkey client-key.pem \
-name "client-pkcs12" \
-out client.p12
2/ Work around Apple-specific things 😵
By the way, @blackbeam , would you be open to adding documentation somewhere for this workaround? I'd be happy to do so myself. I was thinking either:
Or both :)
Additionally, I do think it would be cool to add an API to support passing client certs and keys natively. But I need to do some research on other MySQL libraries, since what I'm used to on the CLI may simply be different than how most client libraries choose to implement TLS 😅
EDIT: Looks like at least Python and Go support key/pairs through various interfaces/APIs:
So lemme poke at it some!
By the way, @blackbeam , would you be open to adding documentation somewhere for this workaround? I'd be happy to do so myself. I was thinking either:
This API is for the native-tls backend (rustls uses separate pem files), so I'd prefer the second option.
Hello! Apologies in advance if this has been answered elsewhere... but I would like to establish a MySQL connection using this crate that is analogous to the following
mysql
CLI invocation:I believe that this has the client verify (via the
/path/to/ca.pem
file) that the server sent along the correct certs. But by passing along the--ssl-cert
and--ssl-key
files as well I am asking the server to verify the client. Ref: https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-certThe closest I got was the https://docs.rs/mysql/latest/mysql/struct.ClientIdentity.html struct, but I was unsure how the client cert and key could be set using this struct?
So far I have something like below. Any help would be greatly appreciated and thanks so much!