Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3b225d8b
Commit
3b225d8b
authored
Jan 18, 2015
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Issue #23248: Update ssl error codes from latest OpenSSL git master.
parents
e6f250ed
173ad83b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
336 additions
and
20 deletions
+336
-20
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_ssl_data.h
Modules/_ssl_data.h
+296
-1
Tools/ssl/make_ssl_data.py
Tools/ssl/make_ssl_data.py
+38
-19
No files found.
Misc/NEWS
View file @
3b225d8b
...
...
@@ -203,6 +203,8 @@ Core and Builtins
Library
-------
-
Issue
#
23248
:
Update
ssl
error
codes
from
latest
OpenSSL
git
master
.
-
Issue
#
23266
:
Much
faster
implementation
of
ipaddress
.
collapse_addresses
()
when
there
are
many
non
-
consecutive
addresses
.
...
...
Modules/_ssl_data.h
View file @
3b225d8b
This diff is collapsed.
Click to expand it.
Tools/ssl/make_ssl_data.py
View file @
3b225d8b
...
...
@@ -5,8 +5,7 @@ This script should be called *manually* when we want to upgrade SSLError
`library` and `reason` mnemnonics to a more recent OpenSSL version.
It takes two arguments:
- the path to the OpenSSL include files' directory
(e.g. openssl-1.0.1-beta3/include/openssl/)
- the path to the OpenSSL source tree (e.g. git checkout)
- the path to the C file to be generated
(probably Modules/_ssl_data.h)
"""
...
...
@@ -15,9 +14,10 @@ import datetime
import
os
import
re
import
sys
import
_ssl
def
parse_error_codes
(
h_file
,
prefix
):
def
parse_error_codes
(
h_file
,
prefix
,
libcode
):
pat
=
re
.
compile
(
r"#define\
W+(%s([
\w]+))\
W+(
\d+)\b"
%
re
.
escape
(
prefix
))
codes
=
[]
with
open
(
h_file
,
"r"
,
encoding
=
"latin1"
)
as
f
:
...
...
@@ -26,7 +26,8 @@ def parse_error_codes(h_file, prefix):
if
match
:
code
,
name
,
num
=
match
.
groups
()
num
=
int
(
num
)
codes
.
append
((
code
,
name
,
num
))
# e.g. ("SSL_R_BAD_DATA", ("ERR_LIB_SSL", "BAD_DATA", 390))
codes
.
append
((
code
,
(
libcode
,
name
,
num
)))
return
codes
if
__name__
==
"__main__"
:
...
...
@@ -34,12 +35,32 @@ if __name__ == "__main__":
outfile
=
sys
.
argv
[
2
]
use_stdout
=
outfile
==
'-'
f
=
sys
.
stdout
if
use_stdout
else
open
(
outfile
,
"w"
)
error_libraries
=
(
# (library code, mnemonic, error prefix, header file)
(
'ERR_LIB_PEM'
,
'PEM'
,
'PEM_R_'
,
'pem.h'
),
(
'ERR_LIB_SSL'
,
'SSL'
,
'SSL_R_'
,
'ssl.h'
),
(
'ERR_LIB_X509'
,
'X509'
,
'X509_R_'
,
'x509.h'
),
)
error_libraries
=
{
# mnemonic -> (library code, error prefix, header file)
'PEM'
:
(
'ERR_LIB_PEM'
,
'PEM_R_'
,
'crypto/pem/pem.h'
),
'SSL'
:
(
'ERR_LIB_SSL'
,
'SSL_R_'
,
'ssl/ssl.h'
),
'X509'
:
(
'ERR_LIB_X509'
,
'X509_R_'
,
'crypto/x509/x509.h'
),
}
# Read codes from libraries
new_codes
=
[]
for
libcode
,
prefix
,
h_file
in
sorted
(
error_libraries
.
values
()):
new_codes
+=
parse_error_codes
(
os
.
path
.
join
(
openssl_inc
,
h_file
),
prefix
,
libcode
)
new_code_nums
=
set
((
libcode
,
num
)
for
(
code
,
(
libcode
,
name
,
num
))
in
new_codes
)
# Merge with existing codes (in case some old codes disappeared).
codes
=
{}
for
errname
,
(
libnum
,
errnum
)
in
_ssl
.
err_names_to_codes
.
items
():
lib
=
error_libraries
[
_ssl
.
lib_codes_to_names
[
libnum
]]
libcode
=
lib
[
0
]
# e.g. ERR_LIB_PEM
errcode
=
lib
[
1
]
+
errname
# e.g. SSL_R_BAD_SSL_SESSION_ID_LENGTH
# Only keep it if the numeric codes weren't reused
if
(
libcode
,
errnum
)
not
in
new_code_nums
:
codes
[
errcode
]
=
libcode
,
errname
,
errnum
codes
.
update
(
dict
(
new_codes
))
def
w
(
l
):
f
.
write
(
l
+
"
\
n
"
)
w
(
"/* File generated by Tools/ssl/make_ssl_data.py */"
)
...
...
@@ -47,21 +68,19 @@ if __name__ == "__main__":
w
(
""
)
w
(
"static struct py_ssl_library_code library_codes[] = {"
)
for
libcode
,
mnemo
,
_
,
_
in
error_libraries
:
for
mnemo
,
(
libcode
,
_
,
_
)
in
sorted
(
error_libraries
.
items
())
:
w
(
' {"%s", %s},'
%
(
mnemo
,
libcode
))
w
(
' { NULL }'
)
w
(
'};'
)
w
(
""
)
w
(
"static struct py_ssl_error_code error_codes[] = {"
)
for
libcode
,
_
,
prefix
,
h_file
in
error_libraries
:
codes
=
parse_error_codes
(
os
.
path
.
join
(
openssl_inc
,
h_file
),
prefix
)
for
code
,
name
,
num
in
sorted
(
codes
):
w
(
' #ifdef %s'
%
(
code
))
w
(
' {"%s", %s, %s},'
%
(
name
,
libcode
,
code
))
w
(
' #else'
)
w
(
' {"%s", %s, %d},'
%
(
name
,
libcode
,
num
))
w
(
' #endif'
)
for
errcode
,
(
libcode
,
name
,
num
)
in
sorted
(
codes
.
items
()):
w
(
' #ifdef %s'
%
(
errcode
))
w
(
' {"%s", %s, %s},'
%
(
name
,
libcode
,
errcode
))
w
(
' #else'
)
w
(
' {"%s", %s, %d},'
%
(
name
,
libcode
,
num
))
w
(
' #endif'
)
w
(
' { NULL }'
)
w
(
'};'
)
if
not
use_stdout
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment