-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
macOS Security Framework fails to import modern PKCS#12 created by OpenSSL 3 #691
Comments
This comment has been minimized.
This comment has been minimized.
@clux Its also happens with |
@clux I pushed the change to my repo to reflect how i use |
Hm. Damn. It runs successfully on linux against my k3d with |
A workaround for this will be to add |
As noted on discord, this is a regression from kube 0.58.0, but only because 0.63 pulls in the new patch release of It would be good to have some more eyes on this particularly upstream to find the underlying issue. Pinning
|
Purging openssl from the dependency tree: [dependencies]
log = "0.4.14"
anyhow = "1.0.44"
kube = { version = "0.63.2", default-features=false, features = ["derive", "rustls-tls", "client"]}
tokio = { version = "1.0.1", features = ["rt-multi-thread", "time", "fs", "macros", "net"] }
k8s-openapi = { version = "0.13.1", features = ["v1_20"], default-features=false } gives the error
from https://github.com/kube-rs/kube-rs/blob/120d0001ce58eb18ac59d2a9da1bf8514bc8058c/kube-client/src/client/tls.rs#L90-L117 - so that's the rustls EC issue again. So it looks like this issue here is related solely to openssl 3.0 (additionally) breaking it on |
This is a problem because that means that soon there could be no good way to run kube against k3d on mac's since both tls stacks have issues (at least if the pinning of openssl-sys stops being available). If anyone is able to dig in here and look for some workarounds it would be really appreciated. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I confirmed https://github.com/danni-m/PKCS12_issue works fine on Linux as well. I think the problem is But pub fn from_pkcs12(der: &[u8], password: &str) -> Result<Identity> {
let identity = imp::Identity::from_pkcs12(der, password)?;
Ok(Identity(identity))
} #[cfg(any(target_os = "macos", target_os = "ios"))]
#[path = "imp/security_framework.rs"]
mod imp;
#[cfg(target_os = "windows")]
#[path = "imp/schannel.rs"]
mod imp;
#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "ios")))]
#[path = "imp/openssl.rs"]
mod imp; Some change in OpenSSL 3 is incompatible with them. |
Probably this:
|
Yeah, found MacOS security framework fails to import RFC 7292 compliant PKCS #12 v1.1 file into keychain using modern cyphers.
|
We should be able to work around this by configuring /// Creates a new builder for a protected pkcs12 certificate.
///
/// This uses the defaults from the OpenSSL library:
///
/// * `nid_key` - `nid::PBE_WITHSHA1AND3_KEY_TRIPLEDES_CBC`
/// * `nid_cert` - `nid::PBE_WITHSHA1AND40BITRC2_CBC`
/// * `iter` - `2048`
/// * `mac_iter` - `2048`
pub fn builder() -> Pkcs12Builder {
ffi::init();
Pkcs12Builder {
nid_key: Nid::UNDEF, //nid::PBE_WITHSHA1AND3_KEY_TRIPLEDES_CBC,
nid_cert: Nid::UNDEF, //nid::PBE_WITHSHA1AND40BITRC2_CBC,
iter: ffi::PKCS12_DEFAULT_ITER,
mac_iter: ffi::PKCS12_DEFAULT_ITER,
ca: None,
}
} Setting the parameters to the commented ones should work. The documentation is outdated with OpenSSL 3. |
I'm hoping PKCS#8 support is merged soon (sfackler/rust-native-tls#209). Once we have that, we don't need to depend on |
@danni-m If #693 still doesn't work after |
Hi All, I may confirm that latest master have same problem. Testing with macOS Monterey.
|
Yeah, it's not fixed. I'd recommend trying PKCS#8 support in |
`native-tls` feature exists because `kube` used to depend on `reqwest`. The feature doesn't make sense for us because all targets still depend on `openssl` anyway. This is because `native-tls` requires PKCS#12 to create `Identity` for authentication with client certificates, and `openssl` is the only trusted option to generate them. A feature to create `Identity` from PKCS#8 was added a few days ago, but `openssl` is still necessary because we need to support more private key formats. `native-tls` feature is currently broken on macOS because Security Framework cannot import PKCS#12 generated by OpenSSL v3 (kube-rs#691). https://openradar.appspot.com/FB8988319 Signed-off-by: kazk <[email protected]>
`native-tls` feature exists because `kube` used to depend on `reqwest`. The feature doesn't make sense for us because all targets still depend on `openssl` anyway. This is because `native-tls` requires PKCS#12 to create `Identity` for authentication with client certificates, and `openssl` is the only trusted option to generate them. A feature to create `Identity` from PKCS#8 was added a few days ago, but `openssl` is still necessary because we need to support more private key formats. `native-tls` feature is currently broken on macOS because Security Framework cannot import PKCS#12 generated by OpenSSL v3 (kube-rs#691). https://openradar.appspot.com/FB8988319 Signed-off-by: kazk <[email protected]>
Hi, i could confirm that now works. Thx. for your great work.
|
Hi,
Im having the following error when running on macbook (M1) with a k3s cluster that was created by k3d:
This doesn't happen if I use GKE or token based authentication.
I have a repository that reproduces this on my machine: https://github.com/danni-m/PKCS12_issue.
The kubeconfig file im using is:
The text was updated successfully, but these errors were encountered: