Skip to content

Commit 82a21de

Browse files
committed
ja3 test
1 parent 62482c2 commit 82a21de

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/test.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,44 @@ fn badssl_cipher_suites_no_rsa() {
600600
// let s = p!(TcpStream::connect("mozilla-intermediate.badssl.com:443"));
601601
// p!(builder.connect("mozilla-intermediate.badssl.com", s));
602602
// }
603+
604+
#[test]
605+
fn ja3_test() {
606+
let builder = p!(TlsConnector::builder()
607+
.supported_cipher_suites(
608+
// Oddly, on Windows, allowing RSA key exchange, but not RSA signature algorithms still
609+
// allows a successful TLS connection, despite there being no non-RSA signature cipher
610+
// suites in the Mozilla Intermediate set AFAICT. Removing RSA from the key exchange
611+
// algorithms causes this test to work as expected.
612+
CipherSuiteSet::default()
613+
.key_exchange_algorithms(&[
614+
TlsKeyExchangeAlgorithm::Dhe,
615+
TlsKeyExchangeAlgorithm::Ecdhe,
616+
TlsKeyExchangeAlgorithm::Rsa,
617+
])
618+
.bulk_encryption_algorithms(&[
619+
TlsBulkEncryptionAlgorithm::Aes128,
620+
TlsBulkEncryptionAlgorithm::Aes256,
621+
])
622+
.signature_algorithms(&[
623+
TlsSignatureAlgorithm::Rsa,
624+
TlsSignatureAlgorithm::Ecdsa,
625+
])
626+
.hash_algorithms(&[
627+
TlsHashAlgorithm::Sha1,
628+
TlsHashAlgorithm::Sha256,
629+
TlsHashAlgorithm::Sha384,
630+
])
631+
)
632+
.build());
633+
let s = p!(TcpStream::connect("check.ja3.zone:443"));
634+
let mut socket = p!(builder.connect("check.ja3.zone", s));
635+
636+
p!(socket.write_all(b"GET / HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15\r\n\r\n"));
637+
let mut result = vec![];
638+
p!(socket.read_to_end(&mut result));
639+
640+
println!("{}", String::from_utf8_lossy(&result));
641+
assert!(result.starts_with(b"HTTP/1.1"));
642+
assert!(result.ends_with(b"}"));
643+
}

0 commit comments

Comments
 (0)