mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Committing patch 405101
This commit is contained in:
parent
261d91a3f9
commit
8f4eab2345
1 changed files with 27 additions and 0 deletions
|
@ -194,6 +194,7 @@ Socket methods:
|
||||||
#include "openssl/pem.h"
|
#include "openssl/pem.h"
|
||||||
#include "openssl/ssl.h"
|
#include "openssl/ssl.h"
|
||||||
#include "openssl/err.h"
|
#include "openssl/err.h"
|
||||||
|
#include "openssl/rand.h"
|
||||||
#endif /* USE_SSL */
|
#endif /* USE_SSL */
|
||||||
|
|
||||||
#if defined(MS_WINDOWS) || defined(__BEOS__)
|
#if defined(MS_WINDOWS) || defined(__BEOS__)
|
||||||
|
@ -2544,6 +2545,32 @@ init_socket(void)
|
||||||
if (PyDict_SetItemString(d, "SSLType",
|
if (PyDict_SetItemString(d, "SSLType",
|
||||||
(PyObject *)&SSL_Type) != 0)
|
(PyObject *)&SSL_Type) != 0)
|
||||||
return;
|
return;
|
||||||
|
if (RAND_status() == 0) {
|
||||||
|
#ifdef USE_EGD
|
||||||
|
char random_device[MAXPATHLEN+1];
|
||||||
|
if (!RAND_file_name (random_device, MAXPATHLEN + 1)) {
|
||||||
|
PyErr_SetObject(SSLErrorObject,
|
||||||
|
PyString_FromString("RAND_file_name error"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (RAND_egd (random_device) == -1) {
|
||||||
|
PyErr_SetObject(SSLErrorObject,
|
||||||
|
PyString_FromString("RAND_egd error"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else /* USE_EGD not defined */
|
||||||
|
char random_string[32];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
PyErr_Warn(PyExc_RuntimeWarning,
|
||||||
|
"using insecure method to generate random numbers");
|
||||||
|
srand(time(NULL));
|
||||||
|
for(i=0; i<sizeof(random_string); i++) {
|
||||||
|
random_string[i] = rand();
|
||||||
|
}
|
||||||
|
RAND_seed(random_string, sizeof(random_string));
|
||||||
|
#endif /* USE_EGD */
|
||||||
|
}
|
||||||
#endif /* USE_SSL */
|
#endif /* USE_SSL */
|
||||||
PyDict_SetItemString(d, "error", PySocket_Error);
|
PyDict_SetItemString(d, "error", PySocket_Error);
|
||||||
PySocketSock_Type.ob_type = &PyType_Type;
|
PySocketSock_Type.ob_type = &PyType_Type;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue