Azure / WALinuxAgent

Microsoft Azure Linux Guest Agent
http://azure.microsoft.com/
Apache License 2.0
541 stars 372 forks source link

Accommodate the new OpenSSL behavior when failed to decrypt certs #3197

Closed nagworld9 closed 3 months ago

nagworld9 commented 3 months ago

Description

fixing https://github.com/Azure/WALinuxAgent/issues/3163

If the decryption fails, old version of openssl overwrite the output file(if exist) with empty data while new version of openssl does not overwrite the output file, so output file may contain old certs data and agent process the old certs again. Correcting the behavior by removing temporary state certificate files.

2024-08-28T00:22:15.391660Z ERROR ExtHandler ExtHandler Failed to decrypt /var/lib/waagent/Certificates.p7m (return code: 1)
[stdout]

[stderr]
Error reading SMIME Content Info
4072163C0D7B0000:error:0680008E:asn1 encoding routines:asn1_d2i_read_bio:not enough data:crypto/asn1/a_d2i_fp.c:216:
4072163C0D7B0000:error:0680006E:asn1 encoding routines:b64_read_asn1:decode error:crypto/asn1/asn_mime.c:151:
4072163C0D7B0000:error:068000CB:asn1 encoding routines:SMIME_read_ASN1_ex:asn1 parse error:crypto/asn1/asn_mime.c:500:

2024-08-28T00:22:15.391869Z INFO ExtHandler ExtHandler Removing temporary state certificate files ['/var/lib/waagent/Certificates.p7m', '/var/lib/waagent/Certificates.pem']
2024-08-28T00:22:15.392123Z INFO ExtHandler ExtHandler Removed file /var/lib/waagent/Certificates.p7m
2024-08-28T00:22:15.392267Z INFO ExtHandler ExtHandler Removed file /var/lib/waagent/Certificates.pem
2024-08-28T00:22:15.392632Z INFO ExtHandler Fetch goal state completed

Issue #


PR information

Quality of Code and Contribution Guidelines

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.

Project coverage is 72.30%. Comparing base (3aebcdd) to head (2181751). Report is 297 commits behind head on develop.

Files with missing lines Patch % Lines
azurelinuxagent/common/utils/cryptutil.py 72.72% 2 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #3197 +/- ## =========================================== + Coverage 71.97% 72.30% +0.32% =========================================== Files 103 114 +11 Lines 15692 16953 +1261 Branches 2486 2448 -38 =========================================== + Hits 11295 12258 +963 - Misses 3881 4131 +250 - Partials 516 564 +48 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.