Server is Single Threaded and is handling all the connections in while(1)
loop, the sockets are blocking but I am using FD_SET options, not sure if
that could be interrupting with the way openssl works, in the code i am
doing accept, then created SSL and CTX and then calling SSL_Accept. I am NOT
using OpenSSL callbacks.

Regarding code, the library i am using is 1.0.0a, but the openssl s_client i
was using that i downloaded and that is 1.0.0c, but i think that should not
cause a problem, as when i try to connect using the client created with
1.0.0a i still get the same error. I tried using OpenSSL s_client just to
shortlist the error to be on server or client side. Just to be sure, i will
reply with the OpenSSL s_client from the same build.

The server WORKS with clients that are NON SSL, but on the connection that i
do SSL it fails with the mentioned error.

PFA the log file for s_client side, I have removed the data it exchanges
between client and server to reduce the log, let me know if this is not
clear, i will rerun and send the whole log.

I tried using s_server and s_client from the same build and it works fine
and it uses the cipher value from log ECDHE-RSA-AES256-SHA. But when i use
s_client from the same build with my server then it dont work. This means
something is wrong with my server code. Not sure what, any suggestions based
on what i mentioend above?

// Harshvir

On Tue, Apr 12, 2011 at 10:31 PM, Dave Thompson <dthomp...@prinpay.com>wrote:

> >       From: owner-openssl-us...@openssl.org On Behalf Of Harshvir Sidhu
> >       Sent: Tuesday, 12 April, 2011 15:13
>
> >       Just to add a note to my last question,
> >       I tried to use openssl.exe s_client -connect IP:PORT
> >       and it gives the following error message in that.
> (reordered)
> >       verify error:num=18:self signed certificate
> >       verify return:1
> >       236:error:140943FC:<snip>:sslv3 alert bad record mac:<snip>
> >       236:error:140790E5:<snip>:.\ssl\s23_lib.c:177:
>
> >       I am using a self signed certificate so this first line makes
> sense,
>
> > but why its giving this SSL alert number 20.
> > Not able to find anything useful for this.
>
> >       I am trying to write the server side code using OpenSSL.
> >       I am getting the following error on SSL_Accept.
> >       error:1408F119:<snip>:decryption failed or bad record mac
>
> s_client got the alert BECAUSE the server got the error.
> The only real problem is that the server got the error.
>
> >       I tried to google on this, everywhere they were mentioning
> > that there was some build error, which was fixed in 0.9.8 build,
> > i am not sure about te sub version, but i am using 1.0.0.a.
> > I also tried using SSL_CTX_check_private_key after i set my server
> > certificate and key, and its returning 1.
>
> There are two fundamental possibilities:
>
> 1. something else in your server is corrupting OpenSSL's data.
> Do you have handshake callbacks e.g. verification, tempdh, etc?
> Is server multithreaded? (Or less likely, using shared memory?)
> Are you using nonblocking I/O with other code 'in between'?
>
>

> 2. the compiled code for OpenSSL does the cipher or MAC wrong.
> This is rare, but can be caused by a compiler bug, or at least
> a 'feature' that is unusual and unexpected by the developers,
> so it tends to be specific to the compiler, target platform,
> and build options especially whether assembler is used but
> also things like optimization, PIC, etc.
>
> + are you sure you're using 1.0.0a? Linenumber 117 for 1408F119
> does NOT match 1.0.0a official source but DOES match 1.0.0c.
>
> + did you build from source, or get a build from someone else?
> What platform and options? What does openssl version -a say?
> (Remembering that it may be false if the build was fiddled.)
> Did you or the other builder do 'make test'?
>
> + do other clients, especially non-OpenSSL ones, cause the same
> error on the server (and get a similar error on the client)?
> Are OpenSSL client(s) the same OpenSSL build (and platform)?
>
> + exactly when does s_client get the error? I'd bet on Finished,
> but to check, run with -state and -msg or -debug.
>
> + what ciphersuite is selected on s_client attempt? On other
> clients that fail, or that work? What happens if you specify
> a ciphersuite with different data-crypto or MAC?
>
> + if you run s_server from same build, with equivalent crypto
> (key/cert, CAs, ciphersuites), does s_client work with it?
>
>
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majord...@openssl.org
>
OpenSSL> s_client -host 10.200.159.172 -port 5000 -state -debug
Loading 'screen' into random state - done
CONNECTED(00000090)
SSL_connect:before/connect initialization
write to 0xa86360 [0xa86bf8] (210 bytes => 210 (0xD2))

SSL_connect:SSLv2/v3 write client hello A
read from 0xa86360 [0xa8c158] (7 bytes => 7 (0x7))

read from 0xa86360 [0xa8c162] (51 bytes => 51 (0x33))

SSL_connect:SSLv3 read server hello A
read from 0xa86360 [0xa8c15b] (5 bytes => 5 (0x5))

read from 0xa86360 [0xa8c160] (679 bytes => 679 (0x2A7))


verify error:num=18:self signed certificate
verify return:1

verify return:1
SSL_connect:SSLv3 read server certificate A
read from 0xa86360 [0xa8c15b] (5 bytes => 5 (0x5))

read from 0xa86360 [0xa8c160] (4 bytes => 4 (0x4))

SSL_connect:SSLv3 read server done A
write to 0xa86360 [0xa81010] (139 bytes => 139 (0x8B))

SSL_connect:SSLv3 write client key exchange A
write to 0xa86360 [0xa81010] (6 bytes => 6 (0x6))

SSL_connect:SSLv3 write change cipher spec A
write to 0xa86360 [0xa81010] (53 bytes => 53 (0x35))

SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
read from 0xa86360 [0xa8c15b] (5 bytes => 5 (0x5))

read from 0xa86360 [0xa8c160] (2 bytes => 2 (0x2))

SSL3 alert read:fatal:bad record mac
SSL_connect:failed in SSLv3 read server session ticket A
3488:error:140943FC:SSL routines:SSL3_READ_BYTES:sslv3 alert bad record mac:.\ss
l\s3_pkt.c:1193:SSL alert number 20
3488:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:.\ssl\s23_lib
.c:184:

---
No client certificate CA names sent
---
SSL handshake has read 758 bytes and written 198 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES256-SHA
    Session-ID:
    Session-ID-ctx:
    Master-Key: 7FED2A3CD53DF6FB0B0EA1B0CB34830608C4CCE72FED5EBB7EB0A0F252ED97B5
0A144EA9547E549165963B54B40BEF59
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    Start Time: 1302696825
    Timeout   : 300 (sec)
    Verify return code: 18 (self signed certificate)
---
error in s_client

Reply via email to