Issue 25404: ssl.SSLcontext.load_dh_params() does not handle unicode filenames properly

Issue25404

Created on 2015-10-14 12:36 by schlenk, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3459 merged christian.heimes, 2017-09-08 18:07
Messages (5)
msg252987 - (view) Author: Michael Schlenker (schlenk) Date: 2015-10-14 12:36
The load_dh_params() method of SSLContext does not properly handle unicode filenames on Windows (like load_verify_location() does).

It should convert any passed unicode path to the filesystem encoding.

This is already fixed in the 3.x head revision, by loading the file via python instead of the OpenSSL BIO functions, but is broken in 2.7.10.

Currently it silently works for most files due to an implicit conversion to string, but with the wrong default encoding instead of filesystem encoding.
msg252988 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2015-10-14 12:38
Right. The workaround is to encode manually the filename:

filename = filename.encode(sys.getfilesystemencoding())
msg252992 - (view) Author: Michael Schlenker (schlenk) Date: 2015-10-14 13:29
Yes, the workaround works.

Would be nice if this could be fixed in a 2.7.11...
msg301488 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-09-06 17:22
Patch welcome :)
msg312784 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-02-25 08:48
New changeset 6e8f395001b026daea047cf225dcca5a973ae824 by Christian Heimes in branch '2.7':
bpo-25404: SSLContext.load_dh_params() non-ASCII path (GH-3459)
https://github.com/python/cpython/commit/6e8f395001b026daea047cf225dcca5a973ae824
History
Date User Action Args
2022-04-11 14:58:22adminsetgithub: 69590
2018-02-25 08:48:17christian.heimessetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-02-25 08:48:04christian.heimessetmessages: + msg312784
2017-09-08 18:08:32christian.heimessetkeywords: - patch
assignee: christian.heimes
2017-09-08 18:07:56christian.heimessetkeywords: + patch
pull_requests: + pull_request3453
2017-09-06 17:22:15christian.heimessetkeywords: + easy (C)
assignee: christian.heimes -> (no value)
messages: + msg301488
2016-09-15 07:49:59christian.heimessetassignee: christian.heimes

components: + SSL
nosy: + christian.heimes

2016-09-08 23:10:13christian.heimessetstage: patch review
2015-10-14 13:29:13schlenksetmessages: + msg252992
2015-10-14 12:38:27vstinnersetmessages: + msg252988
2015-10-14 12:37:39vstinnersetnosy: + ezio.melotti, zach.ware, paul.moore, tim.golden, vstinner, steve.dower
components: + Unicode, Windows
2015-10-14 12:36:27schlenkcreate