m2crypto load from memory to ctx.set_tmp_dh()

makeit.tsxtsx at gmail.com makeit.tsxtsx at gmail.com
Tue Dec 11 07:12:52 EST 2012


o far I have not been able to load the diffie-hellman params on to ctx.set_tmp_dh(), the BIO class should help do that, but "my way" dont works, maybe I need to specify the smime ?

here's what I tried:

1)

dh_params="""
-----BEGIN DH PARAMETERS-----
MIGHAoGBAJyoxPGR3wxcp8Nf5C3w0Jh9tFk/4eRMuimJN8+d9myW/JMuZTHdRslE
b+wBIpMoEC2g9GLnWCgX+Xzu01kDABFO5JAdypVbdscXKyE0423/rxWic8LKy+EG
LGbc716lIxflajBn0uNy0xRDK7xcn9RECRamf7jPPGqMVYBtV+njAgEC
-----END DH PARAMETERS-----
"""
...

dhbio = M2Crypto.BIO.MemoryBuffer(dh_params)
ctx.set_tmp_dh(dhbio)
...
with dhbio = M2Crypto.BIO.MemoryBuffer(str(dh_params)) gives the same result:

Traceback (most recent call last):
  File "bconn.py", line 121, in <module>
    main()
  File "bconn.py", line 88, in main
    ctx.set_tmp_dh(dhbio)
  File "/usr/local/lib/python2.6/dist-packages/M2Crypto/SSL/Context.py", line 190, in set_tmp_dh
    f = BIO.openfile(dhpfile)
  File "/usr/local/lib/python2.6/dist-packages/M2Crypto/BIO.py", line 186, in openfile
    return File(open(filename, mode))
TypeError: coercing to Unicode: need string or buffer, instance found

thx you ! (:



More information about the Python-list mailing list