Skip to content
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

Cannot Use encrypted key #512

Open
bbernays opened this issue Jun 12, 2024 · 0 comments
Open

Cannot Use encrypted key #512

bbernays opened this issue Jun 12, 2024 · 0 comments
Labels
SDK Issue pertains to the SDK itself and not specific to any service

Comments

@bbernays
Copy link

The documentation for generating an API Signing Key is clear that users should set a passphrase.

The documentation says to use openssl to generate the key. I follow the docs and generate the following:

(This is key was generated purely for this issue report and never associated with anything)

bernays@computer-1 oracle % openssl -v                                                                      
OpenSSL 3.3.0 9 Apr 2024 (Library: OpenSSL 3.3.0 9 Apr 2024)

bernays@computer-1 oracle % openssl genrsa -out ~/.oci/oci_api_key.pem -aes128 2048                    
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:

bernays@computer-1 oracle % cat ~/.oci/oci_api_key.pem
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQH//r2y+0Ug11VGQs
dVSCHgICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEAQIEEHCrtAg2894/jkky
JVZQVoEEggTQxEnh+xYYysNI58ds9seeK6P50LSdVJarjX3uj6uCW0roZBVfUM8m
UH6iN2gCDAc5H1tFLZmTp1NCmk9sMb+k46MVvx3+npZAfL9eEd3Pboldd4EVIerK
ZKUjgJEBMRTgus1mmj7dN501rkUhLpXN142TGykC9KUzCQT/nZ0Eqlpq6QUygb2S
9iHsTe0eY2Z0WSlY9nkxYsSXF9mbiE92blsgS1P+C85bVQmA9IRvNZj3dZLgWdP/
t7HlzSOSf6/dp8slaR5yKhhT0JNgXvmTfBQIBAXRLoAoAtpSEMohxQUafsL3ObvH
AXe9U/DgDcU78N/aHB9urvMnuv85OHTgppVEG4WYlAc/wuUBouOvPSuW1NPGtgcY
YThiZ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HXFrqBGMxyRa8DPmFl
66bK/pH9sgY8mk+rTl4fQvM2fKrV7flyxGYebnZvLQKNyUfY706hbwMoNCpxyp0b
wu6OUue9ouu9MShr1vBIyjF5mUmWRU03zoxwyPJ7d+UflIFfGy/036Z/5C6SAMn5
S3/CxRz2bym4jOd5EU2WWUa97QVPAJ7UUyHsrVxHRT+Gt+4GxwlQ8dc=
-----END ENCRYPTED PRIVATE KEY-----

I pass in the passphrase via common.ConfigurationProviderEnvironmentVariables but the issue is that the OCI SDK uses the x509.IsEncryptedPEMBlock function to check if the PEM block is encrypted, this function assumes that the header DEK-Info is present in the file, which openssl does not set.

if x509.IsEncryptedPEMBlock(pemBlock) {
if password == nil {
e = fmt.Errorf("private key password is required for encrypted private keys")
return
}
if decrypted, e = x509.DecryptPEMBlock(pemBlock, password); e != nil {
return
}
}

This means that users that follow the exact directions in the above docs are not able to use this SDK to interact with OCI

@richachugh11 richachugh11 added the SDK Issue pertains to the SDK itself and not specific to any service label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDK Issue pertains to the SDK itself and not specific to any service
Projects
None yet
Development

No branches or pull requests

2 participants