-
Notifications
You must be signed in to change notification settings - Fork 270
Rumqttc: Support for SEC1 encoded ECC keys. #751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey, this issue will be resolved with PR #743 ! Please have a look once, thank you 😁 |
That PR only touches rumqttd, not rumqttc. But I guess both could benefit from full rustls support. |
good catch, I was dealing with lot of PRs at once so lost context of "c" & "d" haha. Please feel free to open PR!
Thank you so much 😁 |
Ah I just implemented it using |
As users explicitly specify which key type they are using while adding key, let's stick with existing code and add an variant 🚀 |
Okay, I went with a hybrid approach. I have added the variant as a way of documenting support for the different key types, but I also kept the read_one() approach of handling the key as it is much cleaner. See #752 . |
Issue with the approach is that if I specify an RSA key using |
Yes that would still work, I agree it is a bit weird. Perhaps makes more sense to get rid of the If you want to make it error on 'wrong key format' you are burdening the user with stuff that actually works automatically but just chose to make more hard to use. |
That was the case due to incorrect use of function, after we correct it, this should not be a problem right? I believe letting users specify which Key format they actually want to use it good, and as it's how it is rn, it won't cause a big breaking change as you mentioned. wdyt? |
I still think it is a mistake to expose those details in your API since rumqtt doesn't need those details to work, but if you insist I will do it your way. Here is my reasoning. Let's say we generate an RSA key with the following command $ openssl version
OpenSSL 3.1.2 1 Aug 2023 (Library: OpenSSL 3.1.2 1 Aug 2023)
$ openssl genrsa -out client.key 2048 Although this is an RSA key, it is encoded in So why not let Rustls deal with this instead of wrapping it in an extra layer that does not abstract anything. For example the MongoDB rust driver also uses rustls and they accept any type of key even though they impose way more restrictions on how to certificates and keys are generated. The user does not need to specify which type they provide. |
I have removed the |
PR #752 is merged now, will close this issue, thank you! |
Expected Behavior
I would like to use an
"ECC"
key with an ECDSA certificate. I have generated the key with the following openssl command:Current Behavior
rumqtt cannot parse this key and this results in a
Tls(NoValidCertInChain)
error.Failure Information (for bugs)
Things go wrong in rumqttc/src/tls.rs
The
ECC()
variant usespkcs8_private_keys()
to parse the key. However my key does not use PKCS#8 encoding, instead it usesSEC1
encoding, which was specifically designed for Elliptic Curve Cryptography. (PKCS#8 can also encode ECC keys, but it involves converting the keys).Rustls does support SEC1 encoding via
ec_private_keys()
. Rumqtt could add support by adding aKey
variant.Perhaps something like this:
I changed
ECC
toPKCS
And addedEC
. This would be a breaking change, so not sure if that is desired. But we could also keep theKey::ECC(k) => rustls_pemfile::pkcs8_private_keys(
variant for backwards compatibility and make it deprecated.It would be in line with the three variants that Rustls has for keys:
I'll be happy to make a PR, but I'd like to check with this crate's preferences first via this issue.
The text was updated successfully, but these errors were encountered: