Answer the question
In order to leave comments, you need to log in
How to make python work with modified OpenSSL (with GOST support)?
I'm trying to get python 2.7 to work with OpenSSL compiled with GOST support. Configured OpenSSL ./config shared zlib enable-rfc3779
and then installed (make depend, make, make test, make install). Added to openssl.conf:
openssl_conf = openssl_def
[openssl_def]
engines = engine_section
[engine_section]
gost = gost_section
[gost_section]
engine_id = gost
default_algorithms = ALL
openssl ciphers | tr ":" "\n" | grep GOST
GOST2001-GOST89-GOST89
GOST94-GOST89-GOST89
import urllib2
print(urllib2.urlopen('https://test.domain.ru/').read())
urllib2.URLError: <urlopen error [Errno 1] _ssl.c:501: error:140920F8:SSL routines:SSL3_GET_SERVER_HELLO:unknown cipher returned>
Answer the question
In order to leave comments, you need to log in
As a result, through trial and error, such a solution was obtained (I will make a reservation that the solution can be said "on the knee", if someone offers options to make it stable, then I will be in favor).
1. In the openssl.cnf config:
- add at the very beginning
- add at the end
[openssl_def]
engines = engine_section
[engine_section]
gost = gost_section
[gost_section]
engine_id = gost
default_algorithms = ALL
openssl ciphers |tr ":" "\n" |grep GOST
openssl engine gost -t
openssl engine
#include <openssl/x509.h>
#include <openssl/err.h>
#include <openssl/rand.h>
SSL_library_init();
SSL_load_error_strings();
Thanks for your decision. I will supplement it with an example of using it to access sites
import ssl
import urllib2
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
ctx.set_ciphers('GOST2001-GOST89-GOST89:GOST94-GOST89-GOST89')
print urllib2.urlopen(" https:// test.domain.ru/ ", context=ctx).read()
Without declaring the context, urllib2 didn't work for me
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question