Closed mirespace closed 3 months ago
@mirespace Thanks for opening the issue. I was able to repro after installing openssl version 3.2.2 as you highlighted. The other thing I noticed is this test uses 2 test certs. One of the cert(certs.xml) decrypted properly (no issues) but other certs-2.xml is failing while decrypting it. As a result, test validation failed.
'/usr/local/ssl/bin/openssl cms -decrypt -in /tmp/GoalStateTestCase_27xaqevo/Certificates.p7m -inkey /tmp/GoalStateTestCase_27xaqevo/TransportPrivate.pem -recip /tmp/GoalStateTestCase_27xaqevo/TransportCert.pem | /usr/local/ssl/bin/openssl pkcs12 -nodes -password pass: -out /tmp/GoalStateTestCase_27xaqevo/Certificates.pem' failed: 1 (Error decrypting CMS using private key)
I tested this in vm as well with sample certs and able to decrypt the cert.
root@ubu24:/var/lib/waagent# rm Certificates.pem
root@ubu24:/var/lib/waagent# /usr/local/ssl/bin/openssl cms -decrypt -in Certificates.p7m -inkey TransportPrivate.pem -recip TransportCert.pem | /usr/local/ssl/bin/openssl pkcs12 -nodes -password pass: -out Certificates.pem
root@ubu24:/var/lib/waagent# ls Certificates.pem
Certificates.pem
So far this is my observation, and I'll continue investigate further
@mirespace thanks for reporting this. @nagworld9 and me looked into this and we need a small change in the Agent to accommodate a difference of behavior in the new openssl. We'll do this within the next couple of weeks.
Thanks @narrieta and @nagworld9 !
Fixed by #3166
Hi team,
Describe the bug: A clear and concise description of what the bug is.
When building WALinuxAgent in Ubuntu 24.10 the following test is failing:
The curious thing is that this was not happening a pair of weeks ago, so I've checked what changed at distro level to see if another package could be impacting WALinuxagent. The suspicious was openssl, and I can confirm it is the cause, but I couldn't discover 100% the underlying root of the problem, because using previous version 3.2.1, the test passes:
Changes between opennsl versions (3.2.1 and 3.2.2): https://github.com/openssl/openssl/blob/openssl-3.2.2/CHANGES.md#changes-between-321-and-322-4-jun-2024
Distro and WALinuxAgent details :
Additional context
I explored different options to get to the point on what is happening, with no luck... so sharing here all the way I did (thanks in advance!):
Checking when openssl is involved in the test, I saw the check_certificates in azurelinuxagent/common/protocol/goal_state.py that calls Certificates(), and it ends calling decrypt_p7m func from CryptUtil in azurelinuxagent/common/utils/cryptutil.py which executes
/usr/bin/openssl cms -decrypt -in Certificates.p7m -inkey TransportPrivate.pem -recip TransportCert.pem | /usr/bin/openssl pkcs12 -nodes -password pass: -out Certificates.pem
.This operation fails once, happening with both openssl 3.2.1 -the "good"- and 3.2.2 - "bad":
But it seems it "recovers" well in one case and it doesn't in the other. I checked how many times are openssl called in bad a good case:
Good
And in the bad is one missing:
Bad
So, I checked if the Certificates.pem generated are different depending on the SSL version, and is not:
Accidentally, when doing a trace with pdb, I jumped out the reading loop when reading that file (to line 621 in azurelinuxagent/common/protocol/goal_state.py) and the test passed.. .I'm sharing that pdb session with you here in case I could give you a clue that I can't be able to identify. I put the breakpoints at the end.
Anything else you need from me, please let me know... Thanks for looking into it!
Miriam