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
049da9e1
Commit
049da9e1
authored
Aug 25, 2007
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Try to get this to build with Visual Studio by moving all the variable
declarations to the beginning of a scope.
parent
4f2c3ddc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
Modules/_ssl.c
Modules/_ssl.c
+24
-17
No files found.
Modules/_ssl.c
View file @
049da9e1
...
...
@@ -119,6 +119,7 @@ static PyObject *
PySSL_SetError
(
PySSLObject
*
obj
,
int
ret
,
char
*
filename
,
int
lineno
)
{
PyObject
*
v
;
char
buf
[
2048
];
char
*
errstr
;
int
err
;
enum
py_ssl_error
p
;
...
...
@@ -186,7 +187,6 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
errstr
=
"Invalid error code"
;
}
char
buf
[
2048
];
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"_ssl.c:%d: %s"
,
lineno
,
errstr
);
v
=
Py_BuildValue
(
"(is)"
,
p
,
buf
);
if
(
v
!=
NULL
)
{
...
...
@@ -208,6 +208,7 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
int
ret
;
int
err
;
int
sockstate
;
int
verification_mode
;
self
=
PyObject_New
(
PySSLObject
,
&
PySSL_Type
);
/* Create new object */
if
(
self
==
NULL
)
...
...
@@ -282,7 +283,7 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
SSL_CTX_set_options
(
self
->
ctx
,
SSL_OP_ALL
);
/* ssl compatibility */
}
int
verification_mode
=
SSL_VERIFY_NONE
;
verification_mode
=
SSL_VERIFY_NONE
;
if
(
certreq
==
PY_SSL_CERT_OPTIONAL
)
verification_mode
=
SSL_VERIFY_PEER
;
else
if
(
certreq
==
PY_SSL_CERT_REQUIRED
)
...
...
@@ -436,6 +437,9 @@ _create_dict_for_X509_NAME (X509_NAME *xname)
{
char
namebuf
[
X509_NAME_MAXLEN
];
int
buflen
;
PyObject
*
name_obj
;
ASN1_STRING
*
value
;
PyObject
*
value_obj
;
X509_NAME_ENTRY
*
entry
=
X509_NAME_get_entry
(
xname
,
index_counter
);
...
...
@@ -444,19 +448,18 @@ _create_dict_for_X509_NAME (X509_NAME *xname)
buflen
=
OBJ_obj2txt
(
namebuf
,
sizeof
(
namebuf
),
name
,
0
);
if
(
buflen
<
0
)
goto
fail0
;
PyObject
*
name_obj
=
PyString_FromStringAndSize
(
namebuf
,
buflen
);
name_obj
=
PyString_FromStringAndSize
(
namebuf
,
buflen
);
if
(
name_obj
==
NULL
)
goto
fail0
;
ASN1_STRING
*
value
=
X509_NAME_ENTRY_get_data
(
entry
);
value
=
X509_NAME_ENTRY_get_data
(
entry
);
unsigned
char
*
valuebuf
=
NULL
;
buflen
=
ASN1_STRING_to_UTF8
(
&
valuebuf
,
value
);
if
(
buflen
<
0
)
{
Py_DECREF
(
name_obj
);
goto
fail0
;
}
PyObject
*
value_obj
=
PyUnicode_DecodeUTF8
((
char
*
)
valuebuf
,
value_obj
=
PyUnicode_DecodeUTF8
((
char
*
)
valuebuf
,
buflen
,
"strict"
);
OPENSSL_free
(
valuebuf
);
if
(
value_obj
==
NULL
)
{
...
...
@@ -483,6 +486,13 @@ PySSL_peercert(PySSLObject *self)
{
PyObject
*
retval
=
NULL
;
BIO
*
biobuf
=
NULL
;
PyObject
*
peer
;
PyObject
*
issuer
;
PyObject
*
version
;
char
buf
[
2048
];
int
len
;
ASN1_TIME
*
notBefore
,
*
notAfter
;
PyObject
*
pnotBefore
,
*
pnotAfter
;
if
(
!
self
->
peer_cert
)
Py_RETURN_NONE
;
...
...
@@ -495,7 +505,7 @@ PySSL_peercert(PySSLObject *self)
if
((
verification
&
SSL_VERIFY_PEER
)
==
0
)
return
retval
;
PyObject
*
peer
=
_create_dict_for_X509_NAME
(
peer
=
_create_dict_for_X509_NAME
(
X509_get_subject_name
(
self
->
peer_cert
));
if
(
peer
==
NULL
)
goto
fail0
;
...
...
@@ -505,7 +515,7 @@ PySSL_peercert(PySSLObject *self)
}
Py_DECREF
(
peer
);
PyObject
*
issuer
=
_create_dict_for_X509_NAME
(
issuer
=
_create_dict_for_X509_NAME
(
X509_get_issuer_name
(
self
->
peer_cert
));
if
(
issuer
==
NULL
)
goto
fail0
;
...
...
@@ -515,23 +525,20 @@ PySSL_peercert(PySSLObject *self)
}
Py_DECREF
(
issuer
);
PyObject
*
version
=
PyInt_FromLong
(
X509_get_version
(
self
->
peer_cert
));
version
=
PyInt_FromLong
(
X509_get_version
(
self
->
peer_cert
));
if
(
PyDict_SetItemString
(
retval
,
"version"
,
version
)
<
0
)
{
Py_DECREF
(
version
);
goto
fail0
;
}
Py_DECREF
(
version
);
char
buf
[
2048
];
int
len
;
/* get a memory buffer */
biobuf
=
BIO_new
(
BIO_s_mem
());
ASN1_TIME
*
notBefore
=
X509_get_notBefore
(
self
->
peer_cert
);
notBefore
=
X509_get_notBefore
(
self
->
peer_cert
);
ASN1_TIME_print
(
biobuf
,
notBefore
);
len
=
BIO_gets
(
biobuf
,
buf
,
sizeof
(
buf
)
-
1
);
PyObject
*
pnotBefore
=
PyString_FromStringAndSize
(
buf
,
len
);
pnotBefore
=
PyString_FromStringAndSize
(
buf
,
len
);
if
(
pnotBefore
==
NULL
)
goto
fail1
;
if
(
PyDict_SetItemString
(
retval
,
"notBefore"
,
pnotBefore
)
<
0
)
{
...
...
@@ -541,11 +548,11 @@ PySSL_peercert(PySSLObject *self)
Py_DECREF
(
pnotBefore
);
BIO_reset
(
biobuf
);
ASN1_TIME
*
notAfter
=
X509_get_notAfter
(
self
->
peer_cert
);
notAfter
=
X509_get_notAfter
(
self
->
peer_cert
);
ASN1_TIME_print
(
biobuf
,
notAfter
);
len
=
BIO_gets
(
biobuf
,
buf
,
sizeof
(
buf
)
-
1
);
BIO_free
(
biobuf
);
PyObject
*
pnotAfter
=
PyString_FromStringAndSize
(
buf
,
len
);
pnotAfter
=
PyString_FromStringAndSize
(
buf
,
len
);
if
(
pnotAfter
==
NULL
)
goto
fail0
;
if
(
PyDict_SetItemString
(
retval
,
"notAfter"
,
pnotAfter
)
<
0
)
{
...
...
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