Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
049da9e1
Kaydet (Commit)
049da9e1
authored
Agu 25, 2007
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Try to get this to build with Visual Studio by moving all the variable
declarations to the beginning of a scope.
üst
4f2c3ddc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
_ssl.c
Modules/_ssl.c
+24
-17
No files found.
Modules/_ssl.c
Dosyayı görüntüle @
049da9e1
...
@@ -119,6 +119,7 @@ static PyObject *
...
@@ -119,6 +119,7 @@ static PyObject *
PySSL_SetError
(
PySSLObject
*
obj
,
int
ret
,
char
*
filename
,
int
lineno
)
PySSL_SetError
(
PySSLObject
*
obj
,
int
ret
,
char
*
filename
,
int
lineno
)
{
{
PyObject
*
v
;
PyObject
*
v
;
char
buf
[
2048
];
char
*
errstr
;
char
*
errstr
;
int
err
;
int
err
;
enum
py_ssl_error
p
;
enum
py_ssl_error
p
;
...
@@ -186,7 +187,6 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
...
@@ -186,7 +187,6 @@ PySSL_SetError(PySSLObject *obj, int ret, char *filename, int lineno)
errstr
=
"Invalid error code"
;
errstr
=
"Invalid error code"
;
}
}
char
buf
[
2048
];
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"_ssl.c:%d: %s"
,
lineno
,
errstr
);
PyOS_snprintf
(
buf
,
sizeof
(
buf
),
"_ssl.c:%d: %s"
,
lineno
,
errstr
);
v
=
Py_BuildValue
(
"(is)"
,
p
,
buf
);
v
=
Py_BuildValue
(
"(is)"
,
p
,
buf
);
if
(
v
!=
NULL
)
{
if
(
v
!=
NULL
)
{
...
@@ -208,6 +208,7 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
...
@@ -208,6 +208,7 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
int
ret
;
int
ret
;
int
err
;
int
err
;
int
sockstate
;
int
sockstate
;
int
verification_mode
;
self
=
PyObject_New
(
PySSLObject
,
&
PySSL_Type
);
/* Create new object */
self
=
PyObject_New
(
PySSLObject
,
&
PySSL_Type
);
/* Create new object */
if
(
self
==
NULL
)
if
(
self
==
NULL
)
...
@@ -282,7 +283,7 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
...
@@ -282,7 +283,7 @@ newPySSLObject(PySocketSockObject *Sock, char *key_file, char *cert_file,
SSL_CTX_set_options
(
self
->
ctx
,
SSL_OP_ALL
);
/* ssl compatibility */
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
)
if
(
certreq
==
PY_SSL_CERT_OPTIONAL
)
verification_mode
=
SSL_VERIFY_PEER
;
verification_mode
=
SSL_VERIFY_PEER
;
else
if
(
certreq
==
PY_SSL_CERT_REQUIRED
)
else
if
(
certreq
==
PY_SSL_CERT_REQUIRED
)
...
@@ -436,6 +437,9 @@ _create_dict_for_X509_NAME (X509_NAME *xname)
...
@@ -436,6 +437,9 @@ _create_dict_for_X509_NAME (X509_NAME *xname)
{
{
char
namebuf
[
X509_NAME_MAXLEN
];
char
namebuf
[
X509_NAME_MAXLEN
];
int
buflen
;
int
buflen
;
PyObject
*
name_obj
;
ASN1_STRING
*
value
;
PyObject
*
value_obj
;
X509_NAME_ENTRY
*
entry
=
X509_NAME_get_entry
(
xname
,
X509_NAME_ENTRY
*
entry
=
X509_NAME_get_entry
(
xname
,
index_counter
);
index_counter
);
...
@@ -444,20 +448,19 @@ _create_dict_for_X509_NAME (X509_NAME *xname)
...
@@ -444,20 +448,19 @@ _create_dict_for_X509_NAME (X509_NAME *xname)
buflen
=
OBJ_obj2txt
(
namebuf
,
sizeof
(
namebuf
),
name
,
0
);
buflen
=
OBJ_obj2txt
(
namebuf
,
sizeof
(
namebuf
),
name
,
0
);
if
(
buflen
<
0
)
if
(
buflen
<
0
)
goto
fail0
;
goto
fail0
;
PyObject
*
name_obj
=
PyString_FromStringAndSize
(
namebuf
,
name_obj
=
PyString_FromStringAndSize
(
namebuf
,
buflen
);
buflen
);
if
(
name_obj
==
NULL
)
if
(
name_obj
==
NULL
)
goto
fail0
;
goto
fail0
;
ASN1_STRING
*
value
=
X509_NAME_ENTRY_get_data
(
entry
);
value
=
X509_NAME_ENTRY_get_data
(
entry
);
unsigned
char
*
valuebuf
=
NULL
;
unsigned
char
*
valuebuf
=
NULL
;
buflen
=
ASN1_STRING_to_UTF8
(
&
valuebuf
,
value
);
buflen
=
ASN1_STRING_to_UTF8
(
&
valuebuf
,
value
);
if
(
buflen
<
0
)
{
if
(
buflen
<
0
)
{
Py_DECREF
(
name_obj
);
Py_DECREF
(
name_obj
);
goto
fail0
;
goto
fail0
;
}
}
PyObject
*
value_obj
=
PyUnicode_DecodeUTF8
((
char
*
)
valuebuf
,
value_obj
=
PyUnicode_DecodeUTF8
((
char
*
)
valuebuf
,
buflen
,
"strict"
);
buflen
,
"strict"
);
OPENSSL_free
(
valuebuf
);
OPENSSL_free
(
valuebuf
);
if
(
value_obj
==
NULL
)
{
if
(
value_obj
==
NULL
)
{
Py_DECREF
(
name_obj
);
Py_DECREF
(
name_obj
);
...
@@ -483,6 +486,13 @@ PySSL_peercert(PySSLObject *self)
...
@@ -483,6 +486,13 @@ PySSL_peercert(PySSLObject *self)
{
{
PyObject
*
retval
=
NULL
;
PyObject
*
retval
=
NULL
;
BIO
*
biobuf
=
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
)
if
(
!
self
->
peer_cert
)
Py_RETURN_NONE
;
Py_RETURN_NONE
;
...
@@ -495,7 +505,7 @@ PySSL_peercert(PySSLObject *self)
...
@@ -495,7 +505,7 @@ PySSL_peercert(PySSLObject *self)
if
((
verification
&
SSL_VERIFY_PEER
)
==
0
)
if
((
verification
&
SSL_VERIFY_PEER
)
==
0
)
return
retval
;
return
retval
;
PyObject
*
peer
=
_create_dict_for_X509_NAME
(
peer
=
_create_dict_for_X509_NAME
(
X509_get_subject_name
(
self
->
peer_cert
));
X509_get_subject_name
(
self
->
peer_cert
));
if
(
peer
==
NULL
)
if
(
peer
==
NULL
)
goto
fail0
;
goto
fail0
;
...
@@ -505,7 +515,7 @@ PySSL_peercert(PySSLObject *self)
...
@@ -505,7 +515,7 @@ PySSL_peercert(PySSLObject *self)
}
}
Py_DECREF
(
peer
);
Py_DECREF
(
peer
);
PyObject
*
issuer
=
_create_dict_for_X509_NAME
(
issuer
=
_create_dict_for_X509_NAME
(
X509_get_issuer_name
(
self
->
peer_cert
));
X509_get_issuer_name
(
self
->
peer_cert
));
if
(
issuer
==
NULL
)
if
(
issuer
==
NULL
)
goto
fail0
;
goto
fail0
;
...
@@ -515,23 +525,20 @@ PySSL_peercert(PySSLObject *self)
...
@@ -515,23 +525,20 @@ PySSL_peercert(PySSLObject *self)
}
}
Py_DECREF
(
issuer
);
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
)
{
if
(
PyDict_SetItemString
(
retval
,
"version"
,
version
)
<
0
)
{
Py_DECREF
(
version
);
Py_DECREF
(
version
);
goto
fail0
;
goto
fail0
;
}
}
Py_DECREF
(
version
);
Py_DECREF
(
version
);
char
buf
[
2048
];
int
len
;
/* get a memory buffer */
/* get a memory buffer */
biobuf
=
BIO_new
(
BIO_s_mem
());
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
);
ASN1_TIME_print
(
biobuf
,
notBefore
);
len
=
BIO_gets
(
biobuf
,
buf
,
sizeof
(
buf
)
-
1
);
len
=
BIO_gets
(
biobuf
,
buf
,
sizeof
(
buf
)
-
1
);
PyObject
*
pnotBefore
=
PyString_FromStringAndSize
(
buf
,
len
);
pnotBefore
=
PyString_FromStringAndSize
(
buf
,
len
);
if
(
pnotBefore
==
NULL
)
if
(
pnotBefore
==
NULL
)
goto
fail1
;
goto
fail1
;
if
(
PyDict_SetItemString
(
retval
,
"notBefore"
,
pnotBefore
)
<
0
)
{
if
(
PyDict_SetItemString
(
retval
,
"notBefore"
,
pnotBefore
)
<
0
)
{
...
@@ -541,11 +548,11 @@ PySSL_peercert(PySSLObject *self)
...
@@ -541,11 +548,11 @@ PySSL_peercert(PySSLObject *self)
Py_DECREF
(
pnotBefore
);
Py_DECREF
(
pnotBefore
);
BIO_reset
(
biobuf
);
BIO_reset
(
biobuf
);
ASN1_TIME
*
notAfter
=
X509_get_notAfter
(
self
->
peer_cert
);
notAfter
=
X509_get_notAfter
(
self
->
peer_cert
);
ASN1_TIME_print
(
biobuf
,
notAfter
);
ASN1_TIME_print
(
biobuf
,
notAfter
);
len
=
BIO_gets
(
biobuf
,
buf
,
sizeof
(
buf
)
-
1
);
len
=
BIO_gets
(
biobuf
,
buf
,
sizeof
(
buf
)
-
1
);
BIO_free
(
biobuf
);
BIO_free
(
biobuf
);
PyObject
*
pnotAfter
=
PyString_FromStringAndSize
(
buf
,
len
);
pnotAfter
=
PyString_FromStringAndSize
(
buf
,
len
);
if
(
pnotAfter
==
NULL
)
if
(
pnotAfter
==
NULL
)
goto
fail0
;
goto
fail0
;
if
(
PyDict_SetItemString
(
retval
,
"notAfter"
,
pnotAfter
)
<
0
)
{
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