-
Notifications
You must be signed in to change notification settings - Fork 253
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
base: master
Are you sure you want to change the base?
certificatePath and certificateKeyPath should be read as binary #1462
Conversation
@@ -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: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
@williambernardet please test this on py2 and py3 both |
With latest version of the agent extension, I've tried to leverage the new certificatePath and certificateKeyPath to read existing certificate, and the extension fails in the following way. As we write them back with 'wb', we need to load them as bytes.
2021/11/16 17:45:24 ERROR:Install failed with error: a bytes-like object is required, not 'str'
2021/11/16 17:45:24 ERROR:Stacktrace: Traceback (most recent call last):
2021/11/16 17:45:24 ERROR: File "./agent.py", line 189, in main
2021/11/16 17:45:24 ERROR: exit_code, output = operationsoperation
2021/11/16 17:45:24 ERROR: File "./agent.py", line 452, in install
2021/11/16 17:45:24 ERROR: fh.write(MONITORING_GCS_CERT_CERTFILE)
2021/11/16 17:45:24 ERROR:TypeError: a bytes-like object is required, not 'str'
2021/11/16 17:45:24 ERROR:
2021/11/16 17:45:24 ERROR:[Microsoft.Azure.Monitor.AzureMonitorLinuxAgent-1.14.5] Install failed with error: a bytes-lik
e object is required, not 'str'
2021/11/16 17:45:24 ERROR:Stacktrace: Traceback (most recent call last):
2021/11/16 17:45:24 ERROR: File "./agent.py", line 189, in main
2021/11/16 17:45:24 ERROR: exit_code, output = operationsoperation
2021/11/16 17:45:24 ERROR: File "./agent.py", line 452, in install
2021/11/16 17:45:24 ERROR: fh.write(MONITORING_GCS_CERT_CERTFILE)
2021/11/16 17:45:24 ERROR:TypeError: a bytes-like object is required, not 'str'
2021/11/16 17:45:24 ERROR:
2021/11/16 17:45:24 [Microsoft.Azure.Monitor.AzureMonitorLinuxAgent-1.14.5] Install,failed,1,Install failed with error:
a bytes-like object is required, not 'str'
2021/11/16 17:45:24 Stacktrace: Traceback (most recent call last):
2021/11/16 17:45:24 File "./agent.py", line 189, in main
2021/11/16 17:45:24 exit_code, output = operationsoperation
2021/11/16 17:45:24 File "./agent.py", line 452, in install
2021/11/16 17:45:24 fh.write(MONITORING_GCS_CERT_CERTFILE)
2021/11/16 17:45:24 TypeError: a bytes-like object is required, not 'str'