This is a throughput graph - how many Map operations is done per second.
One half ... to one tenth of the original throughput.
iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPTiptables -A FORWARD -i wlan0 -o eth0 -j ACCEPTiptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEiptables -t nat -A PREROUTING -i wlan0 -p tcp -m tcp --dport 995 -j REDIRECT --to-ports 8443sslsplit -S logs -A hazelcast-test.pem ssl 0.0.0.0 8443 tcp 0.0.0.0 8080
Originally the Demo should use this Raspberry Pi as a WiFi hotspot and intercept all the TLS communication on port 995.
sslsplit:
We will use a local variant of the demo.
vi mitm-995-local.sh./mitm-995-local.sh
Run the program in Eclipse
java -Djavax.net.debug=ssl:handshake ...
sudo tcpdump -i any -s0 -w https-traffic.pcap 'port 443'
OpenSSL - not only library
Now will come another round.
This time with some recommendations.
Let's do a small recap.
TLSv1.3 is a major rewrite of the specification.
TLS builds on the earlier SSL specifications (1994, 1995, 1996) developed by Netscape Communications for adding the HTTPS protocol to their Navigator web browser.
IETF=The Internet Engineering Task Force (organization behind RFCs)
What we want from our TLS configuration is a Forward Secrecy of Key exchange.
TLS is a framework, Ciphersuite selects how security will be implemented.
https://www.feistyduck.com/library/bulletproof/online/ch-protocol.html#cipher-suites
TLS is a framework, Ciphersuite selects how security will be implemented.
E.g. "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
ECDSA
ECDHE
AES-256-GCM
SHA-384
https://www.feistyduck.com/library/bulletproof/online/ch-protocol.html#cipher-suites
Source: https
How can we achieve the Forward Secrecy in java?
KeyStore keyStore = KeyStore.getInstance("PKCS12");KeyStore trustStore = KeyStore.getInstance("PKCS12");try (InputStream kis = new FileInputStream("keystore.p12"); InputStream tis = new FileInputStream("truststore.p12")) { keyStore.load(kis, password); trustStore.load(tis, "s3crEt".toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(keyStore, password); TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(trustStore); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom()); //... getServerSocketFactory, createSSLEngine, ...}
SSLSocket sslSocket = (SSLSocket) sslContext.getSocketFactory() .createSocket("pop.gmail.com", 995);sslSocket.setEnabledProtocols(new String[] {"TLSv1.2", "TLSv1.3"});sslSocket.setEnabledCipherSuites(new String[] { "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_AES_256_GCM_SHA384"});
call method
String[] getSupportedCipherSuites()
String[] getEnabledCipherSuites()
void setEnabledCipherSuites(String[])
String[] getSupportedProtocols()
String[] getEnabledProtocols()
void setEnabledProtocols(String[])
From class
SSLEngine
SSLSocket
SSLServerSocket
Open Web Application Security Project
Client Server ClientHello --------> ServerHello Certificate* ServerKeyExchange* CertificateRequest* <-------- ServerHelloDone Certificate* ClientKeyExchange CertificateVerify* [ChangeCipherSpec] Finished --------> [ChangeCipherSpec] <-------- Finished Application Data <-------> Application Data
Client ServerKey ^ ClientHelloExch | + key_share* | + signature_algorithms* | + psk_key_exchange_modes* v + pre_shared_key* --------> ServerHello ^ Key + key_share* | Exch + pre_shared_key* v {EncryptedExtensions} ^ Server {CertificateRequest*} v Params {Certificate*} ^ {CertificateVerify*} | Auth {Finished} v <-------- [Application Data*] ^ {Certificate*}Auth | {CertificateVerify*} v {Finished} --------> [Application Data] <-------> [Application Data]
HazelcastInstance hz = HazelcastClient.newHazelcastClient();Map<Integer, User> userCache = hz.getMap("users");User user = userCache.get(id);if (user == null) { user = dbUtil.loadUser(id); userCache.put(id, user);}
Goals:
Hazelcast: 2 members + 4 clients
Java (Zulu/OpenJDK): 8 v 11 v 13
TLS engine: JSSE v BoringSSL
TLS protocol: TLSv1.2 v TLSv1.3
Map
operations executed by clients on cluster membersTLS 1.2
Hazelcast
IMap.put 10%
IMap.get 80%
IMap.set 10%
BoringSSL shines only in Java 8, but its performance dropped when used in newer Java.
TLS 1.3
Hazelcast
IMap.put 10%
IMap.get 80%
IMap.set 10%
OpenJSSE was explicitly enabled TLS1.3 backport in Java.
BoringSSL doesn't work with TLS 1.3 in Java 8.
-XX:+UseOpenJSSE
netty-tcnative
- https://netty.io/wiki/forked-tomcat-native.htmlio.netty:netty-handler
io.netty:netty-tcnative
(dynamicallly linked OpenSSL)io.netty:netty-tcnative-boringssl-static
(statically linked BoringSSL)netty-tcnative
- https://netty.io/wiki/forked-tomcat-native.htmlio.netty:netty-handler
io.netty:netty-tcnative
(dynamicallly linked OpenSSL)io.netty:netty-tcnative-boringssl-static
(statically linked BoringSSL)
import io.netty.buffer.UnpooledByteBufAllocator;import io.netty.handler.ssl.SslContext;import io.netty.handler.ssl.SslContextBuilder;import io.netty.handler.ssl.SslProvider;import javax.net.ssl.SSLEngine;SslContext context = SslContextBuilder.forClient() .trustManager(new File("ca.crt")) .sslProvider(SslProvider.OPENSSL) .build();SSLEngine sslEngine = context.newEngine(UnpooledByteBufAllocator.DEFAULT);
Forked Tomcat Native.
SSLParameters
(SSLSocket
, SSLEngine
) SSLParameters params = sslEngine.getSSLParameters();// Use Server Name Indicationparams.setServerNames(Arrays.asList(new SNIHostName("www.google.com")));// Enable hostname validation (available algorithms: LDAPS, HTTPS)params.setEndpointIdentificationAlgorithm("HTTPS");sslEngine.setSSLParameters(params);
RFCs:
((X509Certificate) certificate).checkValidity()
certbot
- ACME protocol client
Java integration
DOMAIN=java2days.cacek.cz# Obtain Certificate from Let's Encrypt CAcertbot certonly --standalone -d $DOMAIN# Import private key and certificates to a keystoreopenssl pkcs12 -export -out /opt/keystore-$DOMAIN.p12 \ -in /etc/letsencrypt/live/$DOMAIN/fullchain.pem \ -inkey /etc/letsencrypt/live/$DOMAIN/privkey.pem \ -password pass:pass.123
github.com/kwart
twitter.com/jckwart
javlog.cacek.cz
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |