Hello, guys. I’m trying to make a secure connection between the server and the client. To find out, how to use available api (from mbedtls) I used to compile examples from github repository of mbedtls.
After successful compilation I launched the server and the client: ssl_client2.exe and ssl_server2.exe. Yes, the binaries were built on Windows with visual studio 2017. I’ve got next messages. From the server:
. Performing the SSL/TLS handshake… failed
! mbedtls_ssl_handshake returned -0x4eLast error was: -78 - NET - Sending information through the socket failed
And from the client:
. Performing the SSL/TLS handshake… failed
! mbedtls_ssl_handshake returned -0x2700
Unable to verify the server’s certificate. Either it is invalid,
or you didn’t set ca_file or ca_path to an appropriate value.
Alternatively, you may want to use auth_mode=optional for testing purposes.Last error was: -0x2700 - X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
Can somebody explain me what I’m doing wrong?
Next I tried to look at the first example: ssl_server.exe and ssl_client1.exe
I used them as an example for my own implementation. But first I wanted to check if the algo I planned to use was correct. So the algo was to generate certificate for the server and the root certificate with openssl utility and use them for the handshake in next way:
- First I generated keys for certificates:
openssl genrsa -out rootca.key 4096
openssl genrsa -out user.key 2048
- Then I crafted certificates for the server and the root:
openssl req -x509 -new -nodes -key rootca.key -days 365 -out rootca.crt
openssl req -new -key user.key -out user.csr
openssl x509 -req -in user.csr -CA rootca.crt -CAkey rootca.key -CAcreateserial -out user.crt -days 365
- Then I verified the certificates to check that everything was done right:
openssl verify -CAfile rootca.crt rootca.crt
openssl verify -CAfile rootca.crt user.crt
openssl verify -CAfile user.crt user.crt //that was a fail
Client stops it’s working with the next error message:
. Performing the SSL/TLS handshake…c:\work\code\mbedtls-2.12.0\mbedtls-2.12.0\library\ssl_tls.c:4837: x509_verify_cert() returned -9984 (-0x2700)
failed
! mbedtls_ssl_handshake returned -0x2700Last error was: -9984 - X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
What is the reason of such errors?