Hello,
I tested your small program and it seems to work properly, which, I
suppose, means that the problem resides in my client code. I
copy-pasted the output below.
I just find something strange on the server : to write my server code,
I followed a tuto where they initialised a diffie-helman key in the
server side. I was not sure of the utility of that and thus, I
performed several tests with the command you provided : with and
without this initialisation on the server side. In both cases, this
works properly. So, I am a little bit confused about that. I would
want to remove that part, but I am not sure if it may be useful...
I joined my client code. The interesting function is
"wxSSLSocketClient::InitiateSSLSession". This code uses the wxWidgets
library and thus, it uses the wxSocketClient (wxWidgets socket
implementation) with a dedicated BIO so that openssl can handle it.
This code is extracted from the wxEMail project (I am the maintaniner
of this project). But, in this project, I did not implement the server
certificate check stuff. Thus, this version is slighlty modified to
perform those additional checks.
You will easily identify which part is original code and which one is
not because original code was designed to work in static link as well
as dynamic link (with a manual load of library). So, in original code,
all ssl calls are encapsulated in a macro. The modified version
currenlty only support static link, and thus ssl calls are not
encapsulated in the macro.
Note that this code allows performing ssl connection on different
servers and thus, I really think that the BIO part and so on is OK.
The only part that has never been tested is the new part performing
the server certificate check.
Thanks for your help.
Regards,
Brice
D:\home\DbSync1>C:\OpenSSL-Win32\bin\openssl s_client -connect localhost:1212 -C
Afile server.crt
Loading 'screen' into random state - done
CONNECTED(00000738)
depth=0 C = BE, ST = Hainaut, L = Charleroi, O = AMS-Solutions, CN = Brice Andre
, emailAddress =
brice...@xxx.be
verify return:1
---
Certificate chain
0 s:/C=BE/ST=Hainaut/L=Charleroi/O=AMS-Solutions/CN=Brice Andre/emailAddress=br
ice....@xxx.be
i:/C=BE/ST=Hainaut/L=Charleroi/O=AMS-Solutions/CN=Brice Andre/emailAddress=br
ice....@xxx.be
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDnDCCAoQCCQDc4fMRV+0qfzANBgkqhkiG9w0BAQUFADCBjjELMAkGA1UEBhMC
QkUxEDAOBgNVBAgTB0hhaW5hdXQxEjAQBgNVBAcTCUNoYXJsZXJvaTEWMBQGA1UE
ChMNQU1TLVNvbHV0aW9uczEUMBIGA1UEA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lJSl3bu6XXt/u/ZibObTyw==
-----END CERTIFICATE-----
subject=/C=BE/ST=Hainaut/L=Charleroi/O=AMS-Solutions/CN=Brice Andre/emailAddress
=
brice...@xxx.be
issuer=/C=BE/ST=Hainaut/L=Charleroi/O=AMS-Solutions/CN=Brice Andre/emailAddress=
brice...@xxx.be
---
No client certificate CA names sent
---
SSL handshake has read 1774 bytes and written 519 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1
Cipher : DHE-RSA-AES256-SHA
Session-ID: 6F265E53749453BE5C3DD2BFFF4B99A1DBDA559AF76E8C8974A90ABEEED34AF1
Session-ID-ctx:
Master-Key: 142C4C0BA297D034922C619C9C6EF658D66C476386CE0FECD502B3B990FD01BE
FA3C6B067055860A7BD8632B69E49810
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket:
0000 - 86 89 a4 c4 44 8f a9 e4-0d 76 5f 7e 95 3c 3d aa ....D....v_~.<=.
0010 - 05 4b f0 33 bc 09 7e 08-42 0d f6 81 41 52 81 62 .K.3..~.B...AR.b
0020 - 0f cc 2d de 32 84 b2 57-28 fc c3 2c cc 4b 26 42 ..-.2..W(..,.K&B
0030 - 8b f0 8e 99 37 8e fb 63-50 fe ee c6 10 b1 37 da ....7..cP.....7.
0040 - 90 1c 03 ad cb 08 db ff-93 dc 40 1c a1 7a e1 43 ..........@..z.C
0050 - f2 fc d2 3d 86 46 9a 88-d6 6f 25 62 aa 59 41 a9 ...=.F...o%b.YA.
0060 - a6 29 45 dc 47 3b a9 2f-60 bb 34 d2 42 74 d7 48 .)E.G;./`.4.Bt.H
0070 - d7 82 71 66 d5 5c 1d fb-84 86 10 93 d9 59 d1 cd ..qf.\.......Y..
0080 - 72 ac be d8 bc af 23 a1-00 90 a7 4b 68 ef 58 69 r.....#....Kh.Xi
0090 - f5 e7 75 b0 be 33 d4 19-d8 e0 81 b4 b8 37 bc 79 ..u..3.......7.y
Start Time: 1369897977
Timeout : 300 (sec)
Verify return code: 0 (ok)
---
2013/5/29 Dave Thompson <
dtho...@prinpay.com>: