SlideShare a Scribd company logo
Java 9 security enhancements
in practice
Martin Toshev
Prague, 19-20 October 2017
Who am I
Software consultant (CoffeeCupConsulting)
BG JUG board member (http://jug.bg)
OpenJDK and Oracle RBDMS enthusiast
Twitter: @martin_fmi
Martin Toshev Prague, 19-20 October 2017
Agenda
TLS support in JDK
DTLS support in JDK 9
TLS ALPN extension in JDK 9
The rest at a glance …
Martin Toshev Prague, 19-20 October 2017
TLS support in JDK
Martin Toshev Prague, 19-20 October 2017
TLS and the JDK
•Up to JDK 9 TLS 1.0, 1.1 and 1.2 are supported via the JSSE API
•TLS 1.3 specification currently ongoing …
•typically used to secure most types of application protocols
•used for the implementation of SSL VPNs
Martin Toshev Prague, 19-20 October 2017
TLS handshake
client serve
r
1) Client “hello”(TLS version, ciphers)
2) Server “hello”(server cert, TLS version, cipher)
3) Verity server
cert and crypto
params
5) Send secret key
4) Send client cert
7) Client finished
8) Server finished
6) Verity client
cert
9) Exchange encryptedmessages
Martin Toshev Prague, 19-20 October 2017
Java Secure Socket Extension
•Implemented as JCA provider (SunJSSE)
•Core classes part of the javax.net and javax.net.ssl packages
•Provides APIs for blocking and non-blocking mode of operation
•javax.net.ssl.HttpsURLConnection used to simply HTTPs communication
Martin Toshev Prague, 19-20 October 2017
JSSE blocking mode
•Provided by the javax.net.ssl.SSLSocket class
•Used in the same manner as a regular socket
•Handshake might be triggered by:
o Calling startHandshake() on the socket
o Calling getSession() on the socket
o Reading/writing to the socket
Martin Toshev Prague, 19-20 October 2017
JSSE blocking mode (example)
Martin Toshev Prague, 19-20 October 2017
System.setProperty("javax.net.ssl.keyStore", "sample.pfx");
System.setProperty("javax.net.ssl.keyStorePassword", "sample");
SSLServerSocketFactory ssf = (SSLServerSocketFactory)
SSLServerSocketFactory.getDefault();
ServerSocket ss = ssf.createServerSocket(4444);
while (true) {
Socket s = ss.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintStream out = new PrintStream(s.getOutputStream());
String line = null;
while (((line = in.readLine()) != null)) { System.out.println(line); out.println("Hi, client"); }
in.close(); out.close(); s.close();
JSSE blocking mode (example)
Martin Toshev Prague, 19-20 October 2017
System.setProperty("javax.net.ssl.trustStore", "sample.pfx");
System.setProperty("javax.net.ssl.trustStorePassword", "sample");
SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault();
Socket s = ssf.createSocket("127.0.0.1", 4444);
PrintWriter out = new PrintWriter(s.getOutputStream(), true);
out.println("Hi, server.");
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
String x = in.readLine();
System.out.println(x);
out.close(); in.close(); s.close();
JSSE non-blocking mode
•Provided by the javax.net.ssl.SSLEngine
•The wrap() and unwrap() methods used to transfer data
•Handshake might be triggered by
o calling beginHandshake()
o calling wrap()
o calling unwrap()
Martin Toshev Prague, 19-20 October 2017
application byte
buffers
network byte
buffers
TLS handshakewrap unwrap
JSSE non-blocking mode
•Much more complex to use than the SSLSocket API
•Can be used along with the java.nio.channels.SocketChannel API
•The javax.net.debug system property might be very useful for debugging
Martin Toshev Prague, 19-20 October 2017
-
Djavax.net.debug=all
-Djavax.net.debug=SSL, handshake
DTLS support in JDK 9
Martin Toshev Prague, 19-20 October 2017
DTLS
• TLS over an unreliable transport protocol such as UDP
• Reliable and in-order delivery are not guaranteed
• Targets to secure unreliable protocols such as DNS or SIP etc.
• Follows TLS specifications (hence 1.3 in draft)
Martin Toshev Prague, 19-20 October 2017
DTLS vs TLS
• Added explicit sequence number field
• Dropped support for some ciphers (such as RC4)
• Added retransmission timer for resending of packets
• MAC verification failure triggers warning instead of failure
• Added HelloVerifyRequest message in order to identify sender
Martin Toshev Prague, 19-20 October 2017
DTLS in JDK 9
• Support for DTLS 1.0 and 1.2
• Implementation adapted to the JSSE API
• SSEngine typically used along with DatagramSocket
• Implementation based on the SSLEngine API
• … which makes it hard to use directly
Martin Toshev Prague, 19-20 October 2017
DTLS before JDK 9
• Pre-JDK 9 a third party provider such as BCJSSE could be used
• … or external libraries such as OpenSSL via JNI
Martin Toshev Prague, 19-20 October 2017
DTLS in JDK 9
•Ordered delivery provided automatically by SSLEngine
•Sequence number can be retrieved via SSLEngineResult.sequenceNumber()
•Redelivery of failed messages must be done by the application
•… in DTLS handshake messages must be delivered properly
Martin Toshev Prague, 19-20 October 2017
DTLS in JDK 9
• Good examples are provided by the JDK 9 test suite
Martin Toshev Prague, 19-20 October 2017
SSLContext sslContext = SSLContext.getInstance("DTLS");
sslContext.init(…)
SSLEngine engine = sslContext.createSSLEngine();
engine.setUseClientMode(false);
…
TLS ALPN extension in JDK 9
Martin Toshev Prague, 19-20 October 2017
Application Layer Protocol Extension
• Used to identify the application protocol during TLS handshake
• Does not require additional roundtrips (ClientHello message used)
• Allows the server to send different certificates for different protocols
• Typical use case is the HTTP 2 protocol
• … as e.g. HTTP 1.1 and HTTP/2 may both reside on the same TLS endpoint
Martin Toshev Prague, 19-20 October 2017
ALPN in JDK 9
• Before handshake set the supported protocols on the socket/engine:
Martin Toshev Prague, 19-20 October 2017
SSLParameters sslParams = sslSocket.getSSLParameters();
sslParams.setApplicationProtocols(…)
SSLParameters sslParams = sslEngine.getSSLParameters();
sslParams.setApplicationProtocols(…)
ALPN in JDK 9
• Trigger the handshake on the socket/engine – for example:
Martin Toshev Prague, 19-20 October 2017
sslSocket.startHandshake();
sslEngine.beginHandshake();
ALPN in JDK 9
• After handshake you can get the negotiated protocol:
Martin Toshev Prague, 19-20 October 2017
String protocol = sslSocket.getApplicationProtocol();
String protocol = sslEngine.getApplicationProtocol();
Advanced ALPN
• You can also specify custom protocol resolution
Martin Toshev Prague, 19-20 October 2017
sslSocket.setHandshakeApplicationProtocolSelector((serverSocket, clientProtocols) -> {
SSLSession handshakeSession = serverSocket.getHandshakeSession();
String cipher = handshakeSession.getCipherSuite();
int packetBufferSize = handshakeSession.getPacketBufferSize();
if("RC4".equals(cipher) && packetBufferSize > 1024) {
return "protocol1";
} else {
return "protocol2";
}
});
Demo: banking server
Martin Toshev Prague, 19-20 October 2017
FIX protocol integration
Banking server (plain Java)
Alpha protocol integration
Demo application
…
XMPP protocol
SIP protocol
The rest at a glance …
Martin Toshev Prague, 19-20 October 2017
OCSP Stapling for TCP
• Provides a capability for the server to check certificate revocation
• The server typically caches OCSP responses
• Done in order to reduce the number of responses from the OCSP server
• Must be enabled on both the client and the server
Martin Toshev Prague, 19-20 October 2017
-Djdk.tls.client.enableStatusRequestExtension=true
-Dcom.sun.net.ssl.checkRevocation=true
-
Djdk.tls.server.enableStatusRequestExtension=true
PKCS12 Keystores by default
•PKIX (PKCS12) is default type of store if no other is specified
•Replaces JKS as the default keystore
•PKCS12 provides support for stronger cryptographic algorithms
•Provides better interoperability with other systems
Martin Toshev Prague, 19-20 October 2017
Others
• DRBG-Based SecureRandom Implementations
• Utilization of CPU Instructions for GHASH and RSA
• SHA-1 Certificates disabled for certificate validation
• Implementation of the SHA-3 hash algorithms
Martin Toshev Prague, 19-20 October 2017
Summary
• JDK 9 introduces significant set of security features and enhancements
• The major part of them is related to TLS support
• Hopefully this tendency will continue with future releases …
Martin Toshev Prague, 19-20 October 2017
References
Java Platform, Standard Edition What’s New in Oracle JDK 9
https://docs.oracle.com/javase/9/whatsnew/
Java Platform, Standard Edition Security Developer’s Guide
https://docs.oracle.com/javase/9/security/
Martin Toshev Prague, 19-20 October 2017
References
JEP 219: Datagram Transport Layer Security
http://openjdk.java.net/jeps/219
JEP 244: TLS Application-Layer Protocol Negotiation Extension
http://openjdk.java.net/jeps/244
JDK 9 SSL test suite
https://github.com/netroby/jdk9-dev/tree/master/jdk/test/javax/net/ssl
Martin Toshev Prague, 19-20 October 2017
References
Bouncy Castle (D)TLS API and JSSE Provider
https://downloads.bouncycastle.org/fips-java/BC-FJA-(D)TLSUserGuide-
1.0.0.pdf
Introduction to DTLS
https://www.pixelstech.net/article/1459585203-Introduction-to-DTLS
%28Datagram-Transport-Layer-Security%29
DTLS implementation in JDK 9 (changeset)
http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/6721ff11d592
Martin Toshev Prague, 19-20 October 2017

More Related Content

What's hot (20)

PDF
EKAW - Publishing with Triple Pattern Fragments
Ruben Taelman
 
PDF
T6.6 Sensitive Data Activities
OpenAIRE
 
PDF
Alexander Sibiryakov- Frontera
PyData
 
PDF
JCDL 2016 Doctoral Consortium - Web Archive Profiling
Sawood Alam
 
PPTX
MongoDB + Spring
Norberto Leite
 
ODP
Elastic Search
NexThoughts Technologies
 
PPTX
Gh registry day_1_edited
Francis Amaning
 
PDF
iRODS UGM 2018 Fair data management and DISQOVERability
Maarten Coonen
 
PDF
Datafying Bitcoins
Tariq Ahmad
 
PPTX
Back to Basics Webinar 1: Introduction to NoSQL
MongoDB
 
PPTX
Python and MongoDB as a Market Data Platform by James Blackburn
PyData
 
PDF
Data pipelines observability: OpenLineage & Marquez
Julien Le Dem
 
PPTX
Eagle6 Enterprise Situational Awareness
MongoDB
 
PDF
Poster GraphQL-LD: Linked Data Querying with GraphQL
Ruben Taelman
 
PDF
Open core summit: Observability for data pipelines with OpenLineage
Julien Le Dem
 
PDF
Expert Roundtable: The Future of Metadata After Hive Metastore
lakeFS
 
PDF
Data Structures and Performance for Scientific Computing with Hadoop and Dumb...
Austin Benson
 
PDF
MongoDB Schema Design Tips & Tricks
Juan Antonio Roy Couto
 
PDF
OAISRB
Jigar Kadakia
 
PPT
MongoDB Tick Data Presentation
MongoDB
 
EKAW - Publishing with Triple Pattern Fragments
Ruben Taelman
 
T6.6 Sensitive Data Activities
OpenAIRE
 
Alexander Sibiryakov- Frontera
PyData
 
JCDL 2016 Doctoral Consortium - Web Archive Profiling
Sawood Alam
 
MongoDB + Spring
Norberto Leite
 
Elastic Search
NexThoughts Technologies
 
Gh registry day_1_edited
Francis Amaning
 
iRODS UGM 2018 Fair data management and DISQOVERability
Maarten Coonen
 
Datafying Bitcoins
Tariq Ahmad
 
Back to Basics Webinar 1: Introduction to NoSQL
MongoDB
 
Python and MongoDB as a Market Data Platform by James Blackburn
PyData
 
Data pipelines observability: OpenLineage & Marquez
Julien Le Dem
 
Eagle6 Enterprise Situational Awareness
MongoDB
 
Poster GraphQL-LD: Linked Data Querying with GraphQL
Ruben Taelman
 
Open core summit: Observability for data pipelines with OpenLineage
Julien Le Dem
 
Expert Roundtable: The Future of Metadata After Hive Metastore
lakeFS
 
Data Structures and Performance for Scientific Computing with Hadoop and Dumb...
Austin Benson
 
MongoDB Schema Design Tips & Tricks
Juan Antonio Roy Couto
 
MongoDB Tick Data Presentation
MongoDB
 

Similar to Java 9 Security Enhancements in Practice (20)

PDF
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
JPCERT Coordination Center
 
PDF
Jsse
vantinhkhuc
 
PDF
Panama.pdf
Jean-Frederic Clere
 
PDF
Join the Java Evolution GIDS Bangalore & Pune
Heather VanCura
 
PDF
Jetty TLS Troubleshooting
RomanTeresch
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Ana-Maria Mihalceanu
 
PDF
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
PDF
FFM / Panama: A case study with OpenSSL and Tomcat
Jean-Frederic Clere
 
PDF
SSL/TLS for Mortals (JavaZone)
Maarten Mulders
 
PDF
SSL/TLS for Mortals (J-Fall)
Maarten Mulders
 
PDF
SSL/TLS for Mortals (JavaLand)
Maarten Mulders
 
PDF
Javantura v6 - JDK 11 & JDK 12 - Dalibor Topic
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
wolfSSL and TLS 1.3
wolfSSL
 
PDF
SSL/TLS for Mortals (JavaOne 2017)
Maarten Mulders
 
PDF
Jetty TLS troubleshooting
Roman Tereschenko
 
PPTX
Ssl in a nutshell
Frank Kelly
 
PDF
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Julian Robichaux
 
PDF
DEV-1550: Why Java 8? Or, What's a Lambda? – IBM Connect 2017
panagenda
 
PDF
JCP & The Future of Java
Heather VanCura
 
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
JPCERT Coordination Center
 
Join the Java Evolution GIDS Bangalore & Pune
Heather VanCura
 
Jetty TLS Troubleshooting
RomanTeresch
 
Monitoring Java Application Security with JDK Tools and JFR Events.pdf
Ana-Maria Mihalceanu
 
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
FFM / Panama: A case study with OpenSSL and Tomcat
Jean-Frederic Clere
 
SSL/TLS for Mortals (JavaZone)
Maarten Mulders
 
SSL/TLS for Mortals (J-Fall)
Maarten Mulders
 
SSL/TLS for Mortals (JavaLand)
Maarten Mulders
 
Javantura v6 - JDK 11 & JDK 12 - Dalibor Topic
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
wolfSSL and TLS 1.3
wolfSSL
 
SSL/TLS for Mortals (JavaOne 2017)
Maarten Mulders
 
Jetty TLS troubleshooting
Roman Tereschenko
 
Ssl in a nutshell
Frank Kelly
 
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Julian Robichaux
 
DEV-1550: Why Java 8? Or, What's a Lambda? – IBM Connect 2017
panagenda
 
JCP & The Future of Java
Heather VanCura
 
Ad

More from Martin Toshev (20)

PPTX
Building highly scalable data pipelines with Apache Spark
Martin Toshev
 
PPTX
Big data processing with Apache Spark and Oracle Database
Martin Toshev
 
PPTX
Practical security In a modular world
Martin Toshev
 
PPTX
Java 9 sneak peek
Martin Toshev
 
PPTX
Writing Stored Procedures in Oracle RDBMS
Martin Toshev
 
PPTX
Spring RabbitMQ
Martin Toshev
 
PPTX
Security Architecture of the Java platform
Martin Toshev
 
PPTX
Oracle Database 12c Attack Vectors
Martin Toshev
 
PPTX
JVM++: The Graal VM
Martin Toshev
 
PPTX
RxJS vs RxJava: Intro
Martin Toshev
 
PPTX
Security Аrchitecture of Тhe Java Platform
Martin Toshev
 
PPTX
Spring RabbitMQ
Martin Toshev
 
PPTX
Writing Stored Procedures with Oracle Database 12c
Martin Toshev
 
PDF
Concurrency Utilities in Java 8
Martin Toshev
 
PPTX
The RabbitMQ Message Broker
Martin Toshev
 
PPTX
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Martin Toshev
 
PPTX
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Martin Toshev
 
PPTX
Writing Java Stored Procedures in Oracle 12c
Martin Toshev
 
PDF
KDB database (EPAM tech talks, Sofia, April, 2015)
Martin Toshev
 
PDF
Eclipse plug in development
Martin Toshev
 
Building highly scalable data pipelines with Apache Spark
Martin Toshev
 
Big data processing with Apache Spark and Oracle Database
Martin Toshev
 
Practical security In a modular world
Martin Toshev
 
Java 9 sneak peek
Martin Toshev
 
Writing Stored Procedures in Oracle RDBMS
Martin Toshev
 
Spring RabbitMQ
Martin Toshev
 
Security Architecture of the Java platform
Martin Toshev
 
Oracle Database 12c Attack Vectors
Martin Toshev
 
JVM++: The Graal VM
Martin Toshev
 
RxJS vs RxJava: Intro
Martin Toshev
 
Security Аrchitecture of Тhe Java Platform
Martin Toshev
 
Spring RabbitMQ
Martin Toshev
 
Writing Stored Procedures with Oracle Database 12c
Martin Toshev
 
Concurrency Utilities in Java 8
Martin Toshev
 
The RabbitMQ Message Broker
Martin Toshev
 
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Martin Toshev
 
Modularity of The Java Platform Javaday (http://javaday.org.ua/)
Martin Toshev
 
Writing Java Stored Procedures in Oracle 12c
Martin Toshev
 
KDB database (EPAM tech talks, Sofia, April, 2015)
Martin Toshev
 
Eclipse plug in development
Martin Toshev
 
Ad

Recently uploaded (20)

PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PDF
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
PPTX
darshai cross section and river section analysis
muk7971
 
PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PDF
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
PDF
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
PDF
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PDF
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
PPTX
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
PPTX
Seminar Description: YOLO v1 (You Only Look Once).pptx
abhijithpramod20002
 
PDF
this idjfk sgfdhgdhgdbhgbgrbdrwhrgbbhtgdt
WaleedAziz7
 
PPT
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
darshai cross section and river section analysis
muk7971
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PROGRAMMING REQUESTS/RESPONSES WITH GREATFREE IN THE CLOUD ENVIRONMENT
samueljackson3773
 
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Biosensors, BioDevices, Biomediccal.pptx
AsimovRiyaz
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
template.pptxr4t5y67yrttttttttttttttttttttttttttttttttttt
SithamparanaathanPir
 
A Brief Introduction About Robert Paul Hardee
Robert Paul Hardee
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
Explore USA’s Best Structural And Non Structural Steel Detailing
Silicon Engineering Consultants LLC
 
Seminar Description: YOLO v1 (You Only Look Once).pptx
abhijithpramod20002
 
this idjfk sgfdhgdhgdbhgbgrbdrwhrgbbhtgdt
WaleedAziz7
 
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 

Java 9 Security Enhancements in Practice

  • 1. Java 9 security enhancements in practice Martin Toshev Prague, 19-20 October 2017
  • 2. Who am I Software consultant (CoffeeCupConsulting) BG JUG board member (http://jug.bg) OpenJDK and Oracle RBDMS enthusiast Twitter: @martin_fmi Martin Toshev Prague, 19-20 October 2017
  • 3. Agenda TLS support in JDK DTLS support in JDK 9 TLS ALPN extension in JDK 9 The rest at a glance … Martin Toshev Prague, 19-20 October 2017
  • 4. TLS support in JDK Martin Toshev Prague, 19-20 October 2017
  • 5. TLS and the JDK •Up to JDK 9 TLS 1.0, 1.1 and 1.2 are supported via the JSSE API •TLS 1.3 specification currently ongoing … •typically used to secure most types of application protocols •used for the implementation of SSL VPNs Martin Toshev Prague, 19-20 October 2017
  • 6. TLS handshake client serve r 1) Client “hello”(TLS version, ciphers) 2) Server “hello”(server cert, TLS version, cipher) 3) Verity server cert and crypto params 5) Send secret key 4) Send client cert 7) Client finished 8) Server finished 6) Verity client cert 9) Exchange encryptedmessages Martin Toshev Prague, 19-20 October 2017
  • 7. Java Secure Socket Extension •Implemented as JCA provider (SunJSSE) •Core classes part of the javax.net and javax.net.ssl packages •Provides APIs for blocking and non-blocking mode of operation •javax.net.ssl.HttpsURLConnection used to simply HTTPs communication Martin Toshev Prague, 19-20 October 2017
  • 8. JSSE blocking mode •Provided by the javax.net.ssl.SSLSocket class •Used in the same manner as a regular socket •Handshake might be triggered by: o Calling startHandshake() on the socket o Calling getSession() on the socket o Reading/writing to the socket Martin Toshev Prague, 19-20 October 2017
  • 9. JSSE blocking mode (example) Martin Toshev Prague, 19-20 October 2017 System.setProperty("javax.net.ssl.keyStore", "sample.pfx"); System.setProperty("javax.net.ssl.keyStorePassword", "sample"); SSLServerSocketFactory ssf = (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); ServerSocket ss = ssf.createServerSocket(4444); while (true) { Socket s = ss.accept(); BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); PrintStream out = new PrintStream(s.getOutputStream()); String line = null; while (((line = in.readLine()) != null)) { System.out.println(line); out.println("Hi, client"); } in.close(); out.close(); s.close();
  • 10. JSSE blocking mode (example) Martin Toshev Prague, 19-20 October 2017 System.setProperty("javax.net.ssl.trustStore", "sample.pfx"); System.setProperty("javax.net.ssl.trustStorePassword", "sample"); SSLSocketFactory ssf = (SSLSocketFactory) SSLSocketFactory.getDefault(); Socket s = ssf.createSocket("127.0.0.1", 4444); PrintWriter out = new PrintWriter(s.getOutputStream(), true); out.println("Hi, server."); BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream())); String x = in.readLine(); System.out.println(x); out.close(); in.close(); s.close();
  • 11. JSSE non-blocking mode •Provided by the javax.net.ssl.SSLEngine •The wrap() and unwrap() methods used to transfer data •Handshake might be triggered by o calling beginHandshake() o calling wrap() o calling unwrap() Martin Toshev Prague, 19-20 October 2017 application byte buffers network byte buffers TLS handshakewrap unwrap
  • 12. JSSE non-blocking mode •Much more complex to use than the SSLSocket API •Can be used along with the java.nio.channels.SocketChannel API •The javax.net.debug system property might be very useful for debugging Martin Toshev Prague, 19-20 October 2017 - Djavax.net.debug=all -Djavax.net.debug=SSL, handshake
  • 13. DTLS support in JDK 9 Martin Toshev Prague, 19-20 October 2017
  • 14. DTLS • TLS over an unreliable transport protocol such as UDP • Reliable and in-order delivery are not guaranteed • Targets to secure unreliable protocols such as DNS or SIP etc. • Follows TLS specifications (hence 1.3 in draft) Martin Toshev Prague, 19-20 October 2017
  • 15. DTLS vs TLS • Added explicit sequence number field • Dropped support for some ciphers (such as RC4) • Added retransmission timer for resending of packets • MAC verification failure triggers warning instead of failure • Added HelloVerifyRequest message in order to identify sender Martin Toshev Prague, 19-20 October 2017
  • 16. DTLS in JDK 9 • Support for DTLS 1.0 and 1.2 • Implementation adapted to the JSSE API • SSEngine typically used along with DatagramSocket • Implementation based on the SSLEngine API • … which makes it hard to use directly Martin Toshev Prague, 19-20 October 2017
  • 17. DTLS before JDK 9 • Pre-JDK 9 a third party provider such as BCJSSE could be used • … or external libraries such as OpenSSL via JNI Martin Toshev Prague, 19-20 October 2017
  • 18. DTLS in JDK 9 •Ordered delivery provided automatically by SSLEngine •Sequence number can be retrieved via SSLEngineResult.sequenceNumber() •Redelivery of failed messages must be done by the application •… in DTLS handshake messages must be delivered properly Martin Toshev Prague, 19-20 October 2017
  • 19. DTLS in JDK 9 • Good examples are provided by the JDK 9 test suite Martin Toshev Prague, 19-20 October 2017 SSLContext sslContext = SSLContext.getInstance("DTLS"); sslContext.init(…) SSLEngine engine = sslContext.createSSLEngine(); engine.setUseClientMode(false); …
  • 20. TLS ALPN extension in JDK 9 Martin Toshev Prague, 19-20 October 2017
  • 21. Application Layer Protocol Extension • Used to identify the application protocol during TLS handshake • Does not require additional roundtrips (ClientHello message used) • Allows the server to send different certificates for different protocols • Typical use case is the HTTP 2 protocol • … as e.g. HTTP 1.1 and HTTP/2 may both reside on the same TLS endpoint Martin Toshev Prague, 19-20 October 2017
  • 22. ALPN in JDK 9 • Before handshake set the supported protocols on the socket/engine: Martin Toshev Prague, 19-20 October 2017 SSLParameters sslParams = sslSocket.getSSLParameters(); sslParams.setApplicationProtocols(…) SSLParameters sslParams = sslEngine.getSSLParameters(); sslParams.setApplicationProtocols(…)
  • 23. ALPN in JDK 9 • Trigger the handshake on the socket/engine – for example: Martin Toshev Prague, 19-20 October 2017 sslSocket.startHandshake(); sslEngine.beginHandshake();
  • 24. ALPN in JDK 9 • After handshake you can get the negotiated protocol: Martin Toshev Prague, 19-20 October 2017 String protocol = sslSocket.getApplicationProtocol(); String protocol = sslEngine.getApplicationProtocol();
  • 25. Advanced ALPN • You can also specify custom protocol resolution Martin Toshev Prague, 19-20 October 2017 sslSocket.setHandshakeApplicationProtocolSelector((serverSocket, clientProtocols) -> { SSLSession handshakeSession = serverSocket.getHandshakeSession(); String cipher = handshakeSession.getCipherSuite(); int packetBufferSize = handshakeSession.getPacketBufferSize(); if("RC4".equals(cipher) && packetBufferSize > 1024) { return "protocol1"; } else { return "protocol2"; } });
  • 26. Demo: banking server Martin Toshev Prague, 19-20 October 2017 FIX protocol integration Banking server (plain Java) Alpha protocol integration Demo application … XMPP protocol SIP protocol
  • 27. The rest at a glance … Martin Toshev Prague, 19-20 October 2017
  • 28. OCSP Stapling for TCP • Provides a capability for the server to check certificate revocation • The server typically caches OCSP responses • Done in order to reduce the number of responses from the OCSP server • Must be enabled on both the client and the server Martin Toshev Prague, 19-20 October 2017 -Djdk.tls.client.enableStatusRequestExtension=true -Dcom.sun.net.ssl.checkRevocation=true - Djdk.tls.server.enableStatusRequestExtension=true
  • 29. PKCS12 Keystores by default •PKIX (PKCS12) is default type of store if no other is specified •Replaces JKS as the default keystore •PKCS12 provides support for stronger cryptographic algorithms •Provides better interoperability with other systems Martin Toshev Prague, 19-20 October 2017
  • 30. Others • DRBG-Based SecureRandom Implementations • Utilization of CPU Instructions for GHASH and RSA • SHA-1 Certificates disabled for certificate validation • Implementation of the SHA-3 hash algorithms Martin Toshev Prague, 19-20 October 2017
  • 31. Summary • JDK 9 introduces significant set of security features and enhancements • The major part of them is related to TLS support • Hopefully this tendency will continue with future releases … Martin Toshev Prague, 19-20 October 2017
  • 32. References Java Platform, Standard Edition What’s New in Oracle JDK 9 https://docs.oracle.com/javase/9/whatsnew/ Java Platform, Standard Edition Security Developer’s Guide https://docs.oracle.com/javase/9/security/ Martin Toshev Prague, 19-20 October 2017
  • 33. References JEP 219: Datagram Transport Layer Security http://openjdk.java.net/jeps/219 JEP 244: TLS Application-Layer Protocol Negotiation Extension http://openjdk.java.net/jeps/244 JDK 9 SSL test suite https://github.com/netroby/jdk9-dev/tree/master/jdk/test/javax/net/ssl Martin Toshev Prague, 19-20 October 2017
  • 34. References Bouncy Castle (D)TLS API and JSSE Provider https://downloads.bouncycastle.org/fips-java/BC-FJA-(D)TLSUserGuide- 1.0.0.pdf Introduction to DTLS https://www.pixelstech.net/article/1459585203-Introduction-to-DTLS %28Datagram-Transport-Layer-Security%29 DTLS implementation in JDK 9 (changeset) http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/6721ff11d592 Martin Toshev Prague, 19-20 October 2017

Editor's Notes

  • #6: TLS being the predecessor of SSL is not interoperable with SSL …
  • #8: TLS being the predecessor of SSL is not interoperable with SSL …
  • #9: TLS being the predecessor of SSL is not interoperable with SSL …
  • #10: TLS being the predecessor of SSL is not interoperable with SSL …
  • #11: TLS being the predecessor of SSL is not interoperable with SSL …
  • #12: More complex that the SSLSocket API …
  • #13: TLS being the predecessor of SSL is not interoperable with SSL …
  • #26: You can also do the same on an SSLEngine instance …
  • #27: Every box on the diagram is a separate Jigsaw module