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

certificatePath and certificateKeyPath should be read as binary #1462

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AzureMonitorAgent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def install():

if "certificatePath" in protected_settings:
try:
with open(protected_settings.get("certificatePath"), 'r') as f:
with open(protected_settings.get("certificatePath"), 'rb') as f:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code changes the read path, however the error message provided in the PR points to it attempting to write, which happens here:

fh.write(MONITORING_GCS_CERT_CERTFILE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see, it reads it and then writes it. Nevermind on this comment.

MONITORING_GCS_CERT_CERTFILE = f.read()
except Exception as ex:
log_and_exit('Install', MissingorInvalidParameterErrorCode, 'Failed to read certificate {0}: {1}'.format(protected_settings.get("certificatePath"), ex))
Expand All @@ -378,7 +378,7 @@ def install():

if "certificateKeyPath" in protected_settings:
try:
with open(protected_settings.get("certificateKeyPath"), 'r') as f:
with open(protected_settings.get("certificateKeyPath"), 'rb') as f:
MONITORING_GCS_CERT_KEYFILE = f.read()
except Exception as ex:
log_and_exit('Install', MissingorInvalidParameterErrorCode, 'Failed to read certificate key {0}: {1}'.format(protected_settings.get("certificateKeyPath"), ex))
Expand Down