bcgit / bc-csharp

BouncyCastle.NET Cryptography Library (Mirror)
https://www.bouncycastle.org/csharp
MIT License
1.68k stars 558 forks source link

HTTP2 Handshake Failed #323

Open kreationnext opened 3 years ago

kreationnext commented 3 years ago

I am currently trying to implement HTTP/2.0 on this.

My current ja3 signature is 771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-21,29-23-24,0 which is same as google chrome. ALPN is implemented.

The issue is as and when I send the Http2 preface I get internal error [wireshark info] and then the server closes the connection.

Probably its a Http2 handshake error. Don't know though I could be wrong

peterdettman commented 3 years ago

If you have a stack trace, please show it. Are you using BCJSSE or just the TLS library?

kreationnext commented 3 years ago

I am just using the TLS library from org.bouncycastle.tls. It doesn't throw any error that I can stacktrace. This is what I get from wireshark image

The first Encrypted Alert comes after sending the Http2 preface PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n

peterdettman commented 3 years ago
  1. Validate that the TLS handshake is succeeding by checking you are getting a call to notifyHandshakeComplete on your TlsClient instance.
  2. If possible, check that your application-level code is working by using HTTP/2 without TLS.
  3. Is there any attempt at TLS renegotiation happening?
kreationnext commented 3 years ago
  1. Yes I am getting notifyHandshakeComplete.
  2. I want to implement h2 protocol not h2c.
  3. I am testing the site https://www.google.com and the signatures from https://ezdiscord.xyz/fingerprint. No TLS RENEGOTIATION happening.

Note: If I remove h2 from ALPN and use HTTP/1.1 it works perfectly. The Issue occurs only when I use HTTP/2.

Can you do a demo run at your end and test if HTTP/2 works?

kreationnext commented 3 years ago

The issue regarding HTTP2 is solved. It was because of the frame contents which were rejected. So now it works good. Thanks your your help and support