Skip to content

Fix updateCheck._updateWindowsRootCertificates() for Python 3.#11253

Merged
feerrenrut merged 2 commits into
nvaccess:masterfrom
jcsteh:updateWindowsRootCertsFix
Jun 12, 2020
Merged

Fix updateCheck._updateWindowsRootCertificates() for Python 3.#11253
feerrenrut merged 2 commits into
nvaccess:masterfrom
jcsteh:updateWindowsRootCertsFix

Conversation

@jcsteh

@jcsteh jcsteh commented Jun 12, 2020

Copy link
Copy Markdown
Contributor

Link to issue number:

Related to #4803.

Summary of the issue:

updateCheck._updateWindowsRootCertificates is broken in Python 3. This will mean that a system which doesn't have the root SSL certificate used by nvaccess.org (e.g. a clean Windows install) won't be able to check for updates.

Description of how this pull request fixes the issue:

This was missed in the migration to Python 3.
There are two problems that needed to be addressed here:

  1. We use https://www.nvaccess.org/nvdaUpdateCheck as the URL to get the certificate. However, that returns a 404. In Python 2, urllib didn't raise an exception for errors. In Python 3, it does. So, this was raising an exception and preventing us from getting any further.
    To fix this, pass versionType=stable as the query string, which will stop the server from throwing 404.
  2. When getting the peer certificate, we need the raw SSL socket. In Python 3, the way to get that raw socket has changed slightly, so this code had to be adjusted accordingly.

Testing performed:

I don't have a clean system to test this on, but I confirmed that I don't get any exceptions when I do this in the NVDA Python console:

import updateCheck
updateCheck._updateWindowsRootCertificates()

Known issues with pull request:

None.

Change log entry:

Bug fixes:
- It is once again possible to check for NVDA updates on certain systems; e.g. clean Windows installs.

This was missed in the migration to Python 3.
There are two problems that needed to be addressed here:

1. We use https://www.nvaccess.org/nvdaUpdateCheck as the URL to get the certificate. However, that returns a 404. In Python 2, urllib didn't raise an exception for errors. In Python 3, it does. So, this was raising an exception and preventing us from getting any further.
    To fix this, pass versionType=stable as the query string, which will stop the server from throwing 404.
2. When getting the peer certificate, we need the raw SSL socket. In Python 3, the way to get that raw socket has changed slightly, so this code had to be adjusted accordingly.
@josephsl

josephsl commented Jun 12, 2020 via email

Copy link
Copy Markdown
Contributor

@josephsl josephsl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for catching this.

@LeonarddeR

Copy link
Copy Markdown
Collaborator

I wonder whether it could be helpful to hardcode the url in a function kwarg. This way the behavior doesn't differ when calling the function, but third party can reuse it for other urls.

@jcsteh

jcsteh commented Jun 12, 2020 via email

Copy link
Copy Markdown
Contributor Author

@josephsl

josephsl commented Jun 12, 2020 via email

Copy link
Copy Markdown
Contributor

@feerrenrut feerrenrut added this to the 2020.2 milestone Jun 12, 2020

@feerrenrut feerrenrut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @jcsteh

Note: While #5871 is similar, it is likely to remain an issue after this PR is merged.

@jcsteh

jcsteh commented Jun 12, 2020 via email

Copy link
Copy Markdown
Contributor Author

@Brian1Gaff

Brian1Gaff commented Jun 12, 2020 via email

Copy link
Copy Markdown

@feerrenrut feerrenrut merged commit 4fc9cfe into nvaccess:master Jun 12, 2020
@jcsteh jcsteh deleted the updateWindowsRootCertsFix branch May 25, 2026 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants