client/server https exchange key error - https

I want to do Client/Server communication with HTTP/HTTPS encapsulation.
The HTTPS mode is used just for encryption data, i don't need authentification.
For HTTPS connection, I created and installed certificat on server side.
Besides, i developped my server with HttpServerApi lib and my client (Windows) with WinHttp. So Client start request to server, there are a key exchange but the resultat is: Encrypted Alert (21) Decryption failed:
> 192.168.3.138 192.168.1.6 TLSV1 ClientHello
> 192.168.1.6 192.168.3.138 Server Hello, Certificate, Server Hello Done
> 192.168.3.138 192.168.1.6 TLSV1 ClientKeyExchange, Change Cipher Spec, Encrypted Handshake Message
> 192.168.1.6 192.168.3.138 TLSV1 Change Cipher Spec, Evrypted Handshake Message
> 192.168.3.138 192.168.1.6 TLSV1 Application Data, Application Data
> 192.168.3.138 192.168.1.6 TLSV1 Application Data, Application Data
> 192.168.3.138 192.168.1.6 TLSV1 Application Data
> 192.168.3.138 192.168.1.6 TLSV1 Encrypted Alert
this is the wireshark detail (server side), 192.168.3.138 is my client.
In the 192.168.1.6 192.168.3.138 TLSV1 Change Cipher Spec, Evrypted Handshake Message, I've: Header checksum: 0x0000 [incorrect, should be 0x4ac1 (may be caused by "IP cheksum offload"?)]
How can i do the liaison between my server certificate and the port 443 or my Http Server developped?
Thanks

Ok, i find "why Encrypted Alert". I think is just because i'm working with auto-signed certificate for my test!!
I've another question, with HttpServerApi, how can i select one certificate among others certificates?
Thank

Related

Getting "ssl3_get_record:wrong version number" in spring-boot application on GCP Compute Engine

I have created a spring-boot backend java application with a React front end, and I am trying to use the GCP.
I got it working on AppEngine and wanted to put a long-running version of the application on a VM in Compute Engine, but when I deploy it on the vm in compute engine and try to connect to the app with HTTPS it gives me "ssl3_get_record:wrong version number". This is even when I am trying to connect to the app inside of the vm itself with 'localhost'.
It is a pretty cut and dry spring boot application that uses the embedded tomcat server. It contains a WebSecurityConfigureAdaptor and a WebMvcConfigurer for CORS mapping.
Has anyone run into this issue or can give me some guidance on what I need to do to fix it?
EDIT:
Adding curl -i -v https://localhost as requested
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 3001 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS alert, unknown CA (560):
* SSL certificate problem: self signed certificate
* Closing connection 0
curl: (60) SSL certificate problem: self signed certificate
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
ssl3_get_record:wrong version number means the client can't open a connection to the server because they likely don't support the same TLS versions or settings.
SSLv3 was decommissioned quite a while ago. Either it's old an old java version or they never updated the function name. What java versions are you using?
Logs indicates the app may be running on HTTP/2 (ALPN, offering h2) and with TLSv1.3. These are definitely not supported well in old clients in my experience, like what a java enterprise typically uses. Consider disabling HTTP/2 or TLS1.3 and try again.
The widely used and supported SSL version is TLS 1.2 nowadays. See this other question on forcing TLS versions in a java app. Since OpenJDk Java 11 getting javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
The app may be running on a self-signed certificate. You can get a public certificate from let's encrypt.

Twilio SSL Validation - Error 11237

I am relating to Application and invalid certificate errors
When i initiate the call with Twilio REST API, and then pick up the phone, i can hear that error occured and Certificate Invalid - Could not find path to certificate appears in my alert dashboard.
However, certificate is located in the mozila certificate program, i can find certificate at Public All Intermediate Certs List. I dont use self signed certificate.
As soon as i disable SSL Certificate Validation inside Twilio Console Account settings, the problem is gone.
My result from qualys ssl lab are:
Summary:
This server is vulnerable to the POODLE attack. If possible, disable SSL 3 to mitigate. Grade capped to C.
This server accepts RC4 cipher, but only with older protocols. Grade capped to B.
The server does not support Forward Secrecy with the reference browsers.
This server's certificate chain is incomplete. Grade capped to B.
Configuration:
SSL 3 INSECURE
Cipher Suites:
TLS_RSA_WITH_3DES_EDE_CBC_SHA (0xa) WEAK
TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA (0x16) DH 4096 bits FS WEAK
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA (0xc012) ECDH secp256r1 (eq. 3072 bits RSA) FS WEAK
TLS_RSA_WITH_RC4_128_SHA (0x5) INSECURE
TLS_ECDHE_RSA_WITH_RC4_128_SHA (0xc011) ECDH secp256r1 (eq. 3072 bits RSA) FS INSECURE
Protocol details:
Secure Renegotiation Supported
POODLE (SSLv3) Vulnerable INSECURE SSL 3: 0xa
Downgrade attack prevention Yes, TLS_FALLBACK_SCSV supported
RC4 Yes INSECURE
Forward Secrecy With some browsers
Shall i disable SSL or do you have any ideas what can i do?
Twilio developer evangelist here.
I am hoping that your https://ssllabs.com/ssltest has scared you sufficiently enough. You need to upgrade your server from SSLv3 to TLS as SSLv3 and a lot more of your setup is insecure and will not protect you in the face of an attack.
Twilio has deprecated support for SSLv3 and supports TLS. This is likely why you are getting an invalid certificate error.
For the sake of your and your users own security and safety, please upgrade your server.

TLS handshake inside SSLv3 record layer

My Server is configured to accept both SSLv3 and TLS1.0 protocols. But a few clients are sending below handshake parameters and after the server hello, the client drops the connection and sends 'handshare failure(40) alert, not sure if it's the client fault or server.
Here's the initial client hello packet:
Secure Socket Layer
SSLv3 Record Layer: Client Hello
Content Type: Handshake (22)
Version: SSL 3.0 (0x0300) <-----------------
Length: 103
Handshake Protocol: Client Hello
Handshake Type: Client Hello (1)
Length: 78
Version: TLS 1.0 (0x0301) <-------------
Random
Session ID Length: 0
Cipher Suites Length: 18
Cipher Suites (9 suites)
The Record layer is SSL 3.0 but the inside handshake protocol is TLS 1.0. My question is, is this the right way of doing it i.e. using different versions for each layer? if it is what method is it? I can't find it anywhere, I looked through the RFC but can't find any reference. Also, how can I produce such requests?
EDIT: I'm not interested in troubleshooting and fixing the issue, I just want to know how can I send such packets? Any command? And what should I name this method?
i.e. I can use curl or openssl to either use ssl3 or tls1 but that would send same version in both record layer and handshake layer:
curl -v -ssl3 https://www.mywebserver.com
Above curl command would look on wireshark:
EDIT2: Is this even legal? I have been googling around and can't find any example. Is it violating any rfc standards?
Thanks
Yes, this is legal (at least it was clarified in recent TLS specifications).
You can look this up in rfc5246 (TLS 1.2) or in rfc6101 (SSL 3.0) or other rfc's concerning the SSL/TLS. The problem is with the initial version of the record protocol and with the handshake protocol:
rfc5246:
Earlier versions of the TLS specification were not fully clear on
what the record layer version number (TLSPlaintext.version) should
contain when sending ClientHello (i.e., before it is known which
version of the protocol will be employed). Thus, TLS servers
compliant with this specification MUST accept any value {03,XX} as
the record layer version number for ClientHello.
TLS clients that wish to negotiate with older servers MAY send any
value {03,XX} as the record layer version number. Typical values
would be {03,00}, the lowest version number supported by the client,
and the value of ClientHello.client_version.
Regarding the handshake protocol, the client will negotiate the highest version that it has implemented:
client_version: The version of the TLS protocol by which the client wishes to
communicate during this session. This SHOULD be the latest
(highest valued) version supported by the client
I just want to know how can I send such packets? Any command?
openssl s_client -connect www.myserver.com:443 -no_ssl2
should produce something similar to the trace you provided.

Unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out)

I'm going crazy with Apple push notification!
I've developed my app and test notifications following Ray Wanderlich tutorial and everything worked fine until I changed the file .pem with the distribution one and changed the connection string from gateway.sandbox.push-apple.com to gateway.push-apple.com.
Now if I try to send a message the server returns
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195 (Connection timed out)
Failed to connect: 110 Connection timed out
The php file and the .pem file are on a TMDHosting: I try to ask them if port number 2195 is closed because googling I found that the error means port is closed.
Though, I can't understand if the error is linked to the certificate or to the server.
The strange things is that if I follow the procedure with the Terminal to test the .pem file , everything seems to work
CONNECTED(00000003)
depth=1 /C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/C=US/ST=California/L=Cupertino/O=Apple Inc/OU=Internet Services/CN=gateway.push.apple.com
i:/C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C
1 s:/C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C
i:/O=Entrust.net/OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.)/OU=(c) 1999 Entrust.net Limited/CN=Entrust.net Certification Authority (2048)
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIEXTCC..........
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=Cupertino/O=Apple Inc/OU=Internet Services/CN=gateway.push.apple.com
issuer=/C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C
---
No client certificate CA names sent
---
SSL handshake has read 2541 bytes and written 2039 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: CBA98981BB512ED2FDF0C003F4556FDDA564BEBBEFC6528C37D8E0336BC141AEC6D7E014568B334B8330FFFE266E8CB4
Key-Arg : None
Start Time: 1332945845
Timeout : 300 (sec)
Verify return code: 0 (ok)
---
This lets me to think that it's not a .pem problem...
Am I wrong?
I've already read all the similar question here, and tried to change the port number from 2195 to 30, but nothing changes.
Hints?
EDIT: I found that and seems equal to my problem: TMDHosting told me
...you are located under a shared hosting environment and opening a
port for you will be not possible. However note that the address to
which you are making a connection on port 2195 is not associate with
our server. In other words you are trying to make a connection to a
remote server on port 2195. In order to make this connection to the
port specified above you should make sure that the port is opened for
incoming connections on the remote server and not on the server on
which your account with us relies.
Do I need a VPS?
EDIT2:
In the tutorial I followed I found
.. you will need a server that is connected to the internet. Push
notifications are always sent by a server. For development you can use
your Mac as the server (which we’ll do in this tutorial) but for
production use, you need at least something like a VPS (Virtual
Private Server). A cheap shared hosting account is not good enough.
You need to be able to run a background process on the server, install
an SSL certificate, and be able to make outgoing TLS connections on
certain ports. Most shared hosting providers do not let you do this,
although they might if you ask. However, I really recommend using a
VPS host such as Linode.
At last I think I do need a VPS. Can you confirm for sure?
But why if I send push notification with the sandbox server it works properly without VPS?
LAST UPDATE: (hope to help someone) it seems like there was a bug because the right thing is that I cannot send push notification not to the sandbox nor to the production server from my hosting (TMDHosting): my shared hosting has not the 2195 port open. Changed provider: everything works.
Miwi,
Thanks for this detailed writeup.
We are having a similar issue and it is driving us nuts.
When we test the cert, it appears to work, other than:
"verify error:num=20:unable to get local issuer certificate"
Regardless, we get a valid handshake with the command line test of openssl, just as you do.
We can get the sandbox/dev cert to work as well.
Can you let us know what provider you switched to just in case we need to make the switch?
Thanks.

client rejecting server certificate

I am new to HTTPS/SSL.
I need to write a HTTPS client which will reject all the connection by saying unknown CA . As I understand (through wireshark capture) during SSL connection, first client will send the 'client hello' message. In reply to this server will send message with three record - 'server hello', certificate, 'server hello done'.
What I am trying to achieve here is when the server will send certificate, client should always reject it.
I am trying to achieve it with following code but no luck.
How can I get LWP to validate SSL server certificates?
It's ok if solution is in some other language.
It should be enough to do the connection with no (or dummy) CA certificates known to the client. Have you tried setting SSL_ca_path and SSL_ca_file to dummy values?
Edit:
If any language goes, why not try openssls s_client?
openssl s_client -connect www.stackoverflow.com:443

Resources