Skip to content

8349910: Implement JEP 517: HTTP/3 for the HTTP Client API #24751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 525 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
525 commits
Select commit Hold shift + click to select a range
3759c87
Revert unrelated change
djelinski Mar 21, 2025
26cc681
Revert unrelated change
djelinski Mar 21, 2025
63c7bbe
Simplify processAltSvcHeader
djelinski Mar 21, 2025
7c19fc8
Clean up connectionEstablished
djelinski Mar 21, 2025
4da8dbd
http3: upgrade more tests
dfuch Mar 21, 2025
4ca33f5
http3: retry a request only once on ConnectException
jaikiran Mar 21, 2025
8793e84
Remove pointless while loop
djelinski Mar 21, 2025
816012c
Reduce repetitive logging (see refreshDeadline)
djelinski Mar 21, 2025
68a5558
http3: downgrade to HTTP/2 rather than failing if the client config d…
dfuch Mar 21, 2025
1492416
http3: upgrade UnauthorizedTest to use HTTP/3 and also fix 8352623 (p…
dfuch Mar 21, 2025
540c5d9
http3: more tests upgraded
dfuch Mar 21, 2025
40cb71c
http3: improved java/net/httpclient/RequestBuilderTest.java
dfuch Mar 24, 2025
6e9226b
http3: missing @since
dfuch Mar 24, 2025
fd6ca77
http3: make it clearer that StreamLimitException may be raised when s…
dfuch Mar 24, 2025
bcd2073
http3: update StreamFrame::slice
dfuch Mar 24, 2025
892c089
Remove redundant AltSvcFrame.originLength
djelinski Mar 25, 2025
fab8c39
Fix FramesDecoder snippet
djelinski Mar 25, 2025
84e0b6e
Fix FramesDecoder snippet again
djelinski Mar 25, 2025
b224b9b
http3: remove unused method
jaikiran Mar 25, 2025
25d2614
http3: no need for an additional field
jaikiran Mar 25, 2025
e89450e
http3: remove caching of toString()
jaikiran Mar 25, 2025
697b407
http3: remove redundant check
jaikiran Mar 25, 2025
5c51a75
http3: make fields private
jaikiran Mar 25, 2025
4dc27f2
http3: fix typo and remove unused method
jaikiran Mar 25, 2025
bfa3c3c
http3: use typeFieldHasOFF in StreamFrame
jaikiran Mar 25, 2025
386fbf2
http3: minor change to javadoc
jaikiran Mar 25, 2025
2ff12fe
http3: make field private
jaikiran Mar 25, 2025
86e50bd
http3: fix typo in comment
jaikiran Mar 25, 2025
f2cef20
http3: remove unused method
jaikiran Mar 25, 2025
c8502d1
http3: minor code comment cleanup in HttpResponse and StreamFrame
dfuch Mar 25, 2025
77ca235
http3: clarify Http3PushId::pushId, add a link to HTTP/3 RFC
dfuch Mar 25, 2025
e4c8bee
http3: minor cleanup in Http3ExchangeImpl.java
dfuch Mar 25, 2025
acfd90a
Merge remote-tracking branch 'origin/master' into http3
djelinski Mar 26, 2025
ff9c8b8
merge latest changes from master branch
vy Mar 26, 2025
84f7a92
Remove outdated exception spec, fix typo
djelinski Mar 26, 2025
0d35650
Remove unused imports
djelinski Mar 26, 2025
25d7fbe
http3: more accurate debug trace in ExchangeImpl.java
dfuch Mar 26, 2025
45c8b07
http3: properly terminate QuicConnection if first initial packet not …
dfuch Mar 26, 2025
6ad3d75
http3: HttpSlowServerTest.java and LargeResponseTest.java need bigger…
dfuch Mar 26, 2025
1ef3b1a
http3: more reasons for sending CANCEL_PUSH
dfuch Mar 26, 2025
a252f42
Merge remote-tracking branch 'upstream/http3' into http3
vy Mar 27, 2025
271f76c
http3: fix HttpResponseLimitingTest.java for HTTP/3
dfuch Mar 27, 2025
3b32d58
Replace `System.err` with debug logger in `Http3TestServer::submitExc…
vy Mar 27, 2025
e9aea03
Remove TransportParameterId#key
djelinski Mar 28, 2025
c5af305
Use EnumMap as a backing store for transport parameters
djelinski Mar 28, 2025
558c160
Add QuicTransportParameters copy constructor
djelinski Mar 28, 2025
0d516bb
Do not store null values in the map
djelinski Mar 28, 2025
d529219
Remove unnecessary collection access
djelinski Mar 28, 2025
ba49221
Rename index to identifier
djelinski Mar 28, 2025
3aacfdc
Add note to future maintainers
djelinski Mar 28, 2025
af4b739
Fix minimum payload length calculation
djelinski Mar 28, 2025
0b9ef4b
Remove Util class
djelinski Mar 28, 2025
46196fb
Fix StreamFrame offset usage
djelinski Mar 28, 2025
51561cc
Remove unused imports
djelinski Mar 28, 2025
4912ef6
Assign QuicConnection.endpoint early
djelinski Mar 28, 2025
d811e5b
Fix javadoc
djelinski Mar 28, 2025
275f998
http3: improve links in HttpClient implNote
dfuch Mar 31, 2025
d0cd7c9
Move common connectionID code to base class
djelinski Mar 31, 2025
a687b7e
Move common connectionID code to base class
djelinski Mar 31, 2025
131d88e
Move ID factory to endpoint
djelinski Mar 31, 2025
70e8c56
Document why QuicConnectionId implements Comparable
djelinski Mar 31, 2025
27f80cc
http3: Quic vs QUIC in public API doc
dfuch Mar 31, 2025
cf582fa
Enable smaller stateless reset packets
djelinski Mar 31, 2025
e199336
Adjust min packet length in PacketPayloadTest
djelinski Mar 31, 2025
dad2cdb
http3: more debug
dfuch Mar 31, 2025
495bf6d
http3: TerminationCause should preserve timeout exceptions
dfuch Mar 31, 2025
f8aac7c
Remove duplicate setter
djelinski Mar 31, 2025
07225f3
fix corner case in hasError
djelinski Apr 1, 2025
d03baf0
Update QuicConnection code snippet
djelinski Apr 1, 2025
dfdb940
Use a queue instead of a list for byte buffer queuing
djelinski Apr 1, 2025
357ddd3
Update all references to minShortPacketPayloadSize in PacketEncodingTest
djelinski Apr 1, 2025
5f8930f
Reduce the number of volatile reads
djelinski Apr 1, 2025
4ae1032
http3/quic: remove unnecessary exception wrapping in TerminationCause…
jaikiran Apr 1, 2025
6c565ca
http3: revert test change done in 495bf6d00da35e53ef77f76df2ed7da3282…
jaikiran Apr 1, 2025
b600f35
Revert "http3: revert test change done in 495bf6d00da35e53ef77f76df2e…
jaikiran Apr 1, 2025
f65eb0c
http3: simplify future merge with mainline in MultiExchange.java
dfuch Apr 2, 2025
0f40e41
Update docs for connectReader
djelinski Apr 3, 2025
9fa0498
Reword the knownSize comment
djelinski Apr 3, 2025
743887c
Remove unused isHalfClosed method
djelinski Apr 3, 2025
7fd505f
Fix BiDiStreamState docs
djelinski Apr 3, 2025
2c4be89
http3: fix TlsContextTest.java: warmup request should use HTTP/2
dfuch Apr 3, 2025
221906d
Remove duplicate headers methods
djelinski Apr 3, 2025
762ca63
Rename Pending/processed to produced/consumed
djelinski Apr 3, 2025
71cf354
Remove TODO, remove redundant checks, document exception
djelinski Apr 3, 2025
c2bca64
Remove redundant checks
djelinski Apr 3, 2025
a716629
Increase processed data on ResetStream frame receipt
djelinski Apr 3, 2025
0f79f19
Increase stream and connection processed data in one function
djelinski Apr 3, 2025
b66923a
logging changes
djelinski Apr 3, 2025
1b3df46
http3: improve logging message in QuicEndpoint.java
dfuch Apr 3, 2025
00499ee
http3: use component accessor for record
dfuch Apr 3, 2025
5a8a9f7
http3: Http3PushManager should handle same pushId promised twice on t…
dfuch Apr 3, 2025
e0d07a8
http3: PeerUniStreamDispatcher should abandon stream if an IOExceptio…
dfuch Apr 3, 2025
34b8dd8
http3: HTTP/3 test server should not prevent opening two differnt pus…
dfuch Apr 3, 2025
b794f15
sliceOrCopy should fail on buffers where internal capacity is unknown
djelinski Apr 3, 2025
c24760a
http3: initial CSR pre-review comments
dfuch Apr 4, 2025
1ee9368
http3: clarify jdk.httpclient.keepalive.timeout wrt HTTP/3
dfuch Apr 4, 2025
5032548
Fix races in processed data accounting
djelinski Apr 8, 2025
0d46489
Use the correct receivedQuicBytes
djelinski Apr 9, 2025
5408200
Log completed requests immediately
djelinski Apr 9, 2025
f0dad06
8311956: HTTP/3: Add HTTP/3 Push Promise Tests
vy Apr 9, 2025
05d9ba1
Simplify OrderedFlow.receive
djelinski Apr 9, 2025
4320954
http3: fixed some comments
dfuch Apr 10, 2025
d5b424d
http3: more logging in H3MultipleConnectionsToSameHost.java
dfuch Apr 10, 2025
678aa85
http3: assert in java/net/httpclient/CancelledPartialResponseTest.jav…
dfuch Apr 10, 2025
7e9e1cf
http3: prevent TimeoutBasic.java to connect to random HTTP/3 servers
dfuch Apr 10, 2025
46c8e0b
merge latest changes from master branch
vy Apr 10, 2025
aa0a51a
Cleanup qpack code
AlekseiEfimov Apr 10, 2025
d10a1bc
Merge remote-tracking branch 'upstream/http3' into http3
vy Apr 11, 2025
1eab8c2
Remove unused throws clauses
djelinski Apr 15, 2025
e4d2a0e
Remove todo for server side frame constructor
djelinski Apr 15, 2025
2be11a2
Restore mistakenly removed javadoc
AlekseiEfimov Apr 15, 2025
877f0f3
http3: add a (yet undocumented) hs category to Log.java
dfuch Apr 15, 2025
057f434
merge latest changes from master branch
dfuch Apr 15, 2025
5011962
http3: adapt connection label to HttpQuicConnection after merge
dfuch Apr 15, 2025
e2cb896
Add HTTP/3 cases to `HttpResponseConnectionLabelTest`
vy Apr 16, 2025
0f6e85e
http3: more consistent connection labels; the label now includes the …
dfuch Apr 16, 2025
372469b
http3: comment update in Http3PushManager.java
dfuch Apr 17, 2025
6f613fe
http3: CSR feedback: renamed H3DiscoveryMode and associated constants
dfuch Apr 17, 2025
07e5d70
http3: improve logging on reception of stateless reset
dfuch Apr 17, 2025
d15d0a8
http3: increase keepalive timeout in H3MultipleConnectionsToSameHost.…
dfuch Apr 17, 2025
1a32b19
merge latest changes from master branch
dfuch Apr 17, 2025
86996bd
http3: jcheck - fixed bad file permission
dfuch Apr 18, 2025
9c2da66
http3: jcheck - remove trailing white spaces
dfuch Apr 18, 2025
116227c
Rename QuicFlowControlException to QuicStreamLimitException
djelinski Apr 18, 2025
6735141
Remove flow control from stream limit comments
djelinski Apr 18, 2025
40f2050
http3: qpack - allow 0 capacity when max capacity is 0
AlekseiEfimov Apr 18, 2025
30828f4
http3: Artur's review - make methods package private
jaikiran Apr 23, 2025
31c135b
http3: Artur's review - remove commented out code from test
jaikiran Apr 23, 2025
23ba22e
http3: minor improvement to log message
jaikiran Apr 23, 2025
6cd6729
http3: Artur's review - use SecurityUtils.removeFromDisabledTlsAlgs()…
jaikiran Apr 23, 2025
633375f
http3: Use AlgorithmConstraints and OCSP responses when validating se…
jaikiran Apr 24, 2025
22b4560
http3: improve documentation for Http3DiscoveryMode.ALT_SVC
dfuch Apr 24, 2025
b90b18d
http3: add missing <p> separator to Http3DiscoveryMode.ALT_SVC API do…
dfuch Apr 24, 2025
4da61bb
merge latest changes from master branch
dfuch Apr 24, 2025
c8d5df2
http3: jep review feedback: rename HttpRequest.HttpRequestOption into…
dfuch Apr 29, 2025
dfa2604
merge latest changes from master branch
dfuch Apr 29, 2025
9156a51
merge latest changes from master branch
vy Apr 30, 2025
d58b1f3
8354275: Add HTTP/3 tests to `EmptyAuthenticate`
vy May 1, 2025
6137044
Merge remote-tracking branch 'origin/master' into http3
djelinski May 5, 2025
6dd2f96
Update throws clauses
djelinski May 5, 2025
a1e4547
Remove unnecessary import
djelinski May 5, 2025
e3c6aa7
Remove leftover file (test was moved to parent directory)
djelinski May 6, 2025
b34c893
Fix test license
djelinski May 7, 2025
871b6b7
Merge remote-tracking branch 'origin/master' into http3
djelinski May 7, 2025
89cc2d2
Remove unnecessary import
djelinski May 8, 2025
eb896c4
Undo whitespace change
djelinski May 8, 2025
8c27f53
merge latest changes from master branch
dfuch May 9, 2025
9c6f625
Remove QuicFrame payload and offset
djelinski May 9, 2025
f1f67ca
Fold computeReservedInitialPayloadSize into computeMaxInitialPayloadSize
djelinski May 12, 2025
7390421
Avoid busy-looping on a closed endpoint
djelinski May 12, 2025
8e9793a
Rename stopReading to readingPaused
djelinski May 12, 2025
6df15ff
Move decoding methods from QuicPacket to QuicPacketDecoder
djelinski May 12, 2025
5c4a6a2
Revert experimental ContinuationFrameTest changes
djelinski May 12, 2025
44e8a3b
http3: fix typo in test - jdk.tls.disabledAlgorithms is a security pr…
jaikiran Apr 24, 2025
2bc7fa4
Artur's review - rename allowedAlgorithms to supportedAlgorithms
jaikiran May 13, 2025
e11998d
Artur's review - introduce a private getUserSpecifiedConstraints() fo…
jaikiran May 13, 2025
9f7f9e1
http3: remove unused method
jaikiran May 13, 2025
10e3e35
http3: Artur's review - remove conditional check in X509TrustManagerI…
jaikiran May 13, 2025
368f9b5
http3: address Sean's review comment for H3QuicTLSConnection and in g…
jaikiran May 13, 2025
1b75ef8
Artur's review: X509Authentication when choosing client/server alias …
jaikiran May 13, 2025
df4898e
Do not open new streams after GOAWAY
djelinski May 13, 2025
afbaf47
Only increase processed data if stopSending was not sent
djelinski May 13, 2025
f750e8d
Only increase processed data if stopSending was not sent
djelinski May 13, 2025
fe7054f
Merge remote-tracking branch 'origin/master' into http3
djelinski May 14, 2025
5267e8e
Port JDK-8353578 Refactor HKDF usage to use KDF API
djelinski May 14, 2025
9d0ec22
Destroy keys after use
djelinski May 14, 2025
36ca0a8
derive IV using deriveData
djelinski May 14, 2025
600d863
Remove unneeded catch block
djelinski May 14, 2025
49a72f0
http3: remove unused import
jaikiran May 13, 2025
7dba9ca
http3: increase PTO backoff time in test
jaikiran May 14, 2025
dd8f0bc
http3: test server fix - return 404 response instead of RuntimeExcept…
jaikiran May 14, 2025
9ae0a57
http3: test server cleanup to return null handler instead of raising …
jaikiran May 14, 2025
735c9b5
Recalculate PSK after updating transport parameters
djelinski May 15, 2025
b96c730
quic: do not skip sending of PING frames for non-1RTT packet space
jaikiran May 16, 2025
bbfd501
quic: improve debuggability of log/exception messages when QUIC idle …
jaikiran May 16, 2025
aa42bef
http3: HTTP/3 connection should not set a quic idle timeout lesser th…
dfuch May 16, 2025
4ed32d5
http3: preserve StreamLimitReached exceptions while connection is clo…
dfuch May 16, 2025
b81a559
http3: provide more diagnosis when connections are closed in quic idl…
dfuch May 16, 2025
6ce42f4
http3: better comments in QuicEndpoint and QuicSelector. Remove redun…
dfuch May 16, 2025
8782372
Remove misplaced call to retry
djelinski May 20, 2025
88f5315
quic: do not start the idle timeout manager for a QUIC connection unt…
jaikiran May 20, 2025
9125717
quic: test server only change - log if onHandshakeCompletion() fails
jaikiran May 20, 2025
ad0cf42
quic: remove unused method
jaikiran May 20, 2025
5a771d8
quic: prevent NullPointerException in log message when token is null
jaikiran May 20, 2025
c6d648a
http3: remove usages of outdated jdk.tracePinnedThreads system proper…
jaikiran May 21, 2025
d363ab5
quic: move utility method containsConnectionClose() out of QuicPacket
jaikiran May 21, 2025
106b801
Synchronize Versions and Retry with transmission task
djelinski May 21, 2025
9d5bfcd
quic: reintroduce unused methods for future use
jaikiran May 22, 2025
ee96f28
http3: Http3ClientImpl should not swallow exceptions when waking waiters
dfuch May 22, 2025
be31391
http3: add more logging to tests
dfuch May 22, 2025
6611c82
quic: fix typo
jaikiran May 22, 2025
31f5197
merge latest from master branch
jaikiran May 22, 2025
d7ff1de
http3: RedirectTimeoutTest.java should have a warmup for HTTP/3 too
dfuch May 22, 2025
bd817c0
http3: unused import in RedirectTimeoutTest.java
dfuch May 22, 2025
007d95a
merge latest http3 changes
jaikiran May 23, 2025
8110b31
quic: fix typo
jaikiran May 23, 2025
87b7327
quic: improve the log message to make it clear when the QUIC idle tim…
jaikiran May 23, 2025
9449b90
quic: minor code comment change and a log message addition
jaikiran May 27, 2025
8bbf552
http3: do not allow "marked for shutdown" connections to idle terminate
jaikiran May 27, 2025
4106b0f
Remove request timeout from H3MemoryHandlingTest
djelinski May 27, 2025
74c27e9
quic: minor exception message improvement for stateless reset
jaikiran May 28, 2025
2e8c2ab
merge lastest from master branch
jaikiran May 29, 2025
8d53b08
Update method documentation
djelinski May 29, 2025
78ed9c1
Fix javadoc
djelinski May 29, 2025
fc03aac
Update method documentation
djelinski May 29, 2025
5605719
http3: increase wait in StreamFlowControlTest.java
dfuch May 29, 2025
89dcc99
http3: improve QuicTimerQueue:stop
dfuch May 29, 2025
4ab2dba
merge http3 changes
jaikiran May 29, 2025
ef465cf
Actually call keepAlive after sending a packet
djelinski May 30, 2025
f54fe26
Print all transport parameter values
djelinski Jun 2, 2025
0cfcecf
Test H3 server: close connection if control stream closed
djelinski Jun 2, 2025
e9098e7
Fix race in test server's Http3StreamDispatcher
djelinski Jun 2, 2025
e4b3276
Remove outdated TODO
djelinski Jun 2, 2025
1e622ba
Remove cryptic TODO
djelinski Jun 2, 2025
a90a440
Remove outdated TODO
djelinski Jun 2, 2025
fd1aef9
Remove outdated TODO
djelinski Jun 2, 2025
3a287f3
Ignore DestroyFailedExceptions
djelinski Jun 3, 2025
93a184e
http3: refactor HTTP/3 connection pool management in a separate class
dfuch Jun 3, 2025
1abbb7f
http3: fix bug introduced by Http3ConnectionPool and improved debug logs
dfuch Jun 3, 2025
a41217f
merge latest changes from master branch
dfuch Jun 4, 2025
e503537
Improve key destruction
djelinski Jun 5, 2025
99d3c1e
Fix snippet
djelinski Jun 5, 2025
2cbb064
http3: improve H3ConnectionPoolTest.java
dfuch Jun 5, 2025
a5a0c7f
merge latest changes from master branch
dfuch Jun 6, 2025
7c1f31d
quic: do not let h3 idle (in pool) timeout to influence the quic tran…
jaikiran Jun 2, 2025
2140d54
http3: rely on the sole isOpen() method instead of isOpen() and isClo…
jaikiran Jun 2, 2025
75bd7fb
quic: simplify idle timeout management
jaikiran Jun 2, 2025
ac6499c
quic: separate out the idle termination timer and the STREAM_DATA_BLO…
jaikiran Jun 6, 2025
4cee27b
merge latest changes from master branch
dfuch Jun 11, 2025
c4bcb39
http3: update H3InsertionsLimitTest to start after receival of client…
AlekseiEfimov Jun 11, 2025
d4984d5
merge latest changes from master branch
dfuch Jun 12, 2025
9f202c8
http3: qpack - recalculate Huffman value when changing TableEntry ty…
AlekseiEfimov Jun 13, 2025
54a5ccb
http3: qpack - maintain one EncoderInstructionsWriter per Encoding c…
AlekseiEfimov Jun 14, 2025
dde844c
http3: improved Http3ClientImpl and pending connections map to take i…
dfuch Jun 17, 2025
63e3662
http3: fix H3GoAwayTest.java to avoid proxy and port stealing issues
dfuch Jun 17, 2025
cc26511
Artur's review - rename applyCertPathAlgConstraints to withDefaultCer…
jaikiran Jun 24, 2025
1875396
Artur's review: fix check for TLSv1.3 in getAlgorithmConstraints()
jaikiran Jun 24, 2025
0863c7b
Replace unsupported algorithm name with a real one
djelinski Jun 25, 2025
d4031c0
Replace 3DES with a more modern cipher suite
djelinski Jun 25, 2025
fefa748
Remove unused else clauses
djelinski Jun 25, 2025
70142b1
Implement X509TrustManagerImpl#checkClientTrusted for QUIC
djelinski Jun 25, 2025
249858a
http3: review feedback - revert HPACK.java
dfuch Jun 25, 2025
33de679
http3: fix exception handling in CancelRequestTest.java
dfuch Jun 25, 2025
0843d3e
http3: improve exceptions in Http3ServerExchange.java
dfuch Jun 25, 2025
a33ea31
http3: fix race with ping requests in PacketSpaceManager.java causing…
dfuch Jun 25, 2025
ea6cced
http3: pending acknowledgement should be registered before actually s…
dfuch Jun 25, 2025
ca830ec
http3: fix pending connection and reconnection on stream limit reache…
dfuch Jun 25, 2025
800b565
retry the ResetControlStream test as needed
djelinski Jun 26, 2025
8f89ef4
http3: run H3StreamLimitReachedTest.java with -Djdk.httpclient.http3.…
dfuch Jun 26, 2025
0229c21
merge latest changes from master branch
dfuch Jun 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.internal.net.quic;


import java.util.Objects;

import jdk.internal.net.quic.QuicTLSEngine.KeySpace;

/**
* Thrown when an operation on {@link QuicTLSEngine} doesn't have the necessary
* QUIC keys for encrypting or decrypting packets. This can either be because
* the keys aren't available for a particular {@linkplain KeySpace keyspace} or
* the keys for the {@code keyspace} have been discarded.
*/
public final class QuicKeyUnavailableException extends Exception {
@java.io.Serial
private static final long serialVersionUID = 8553365136999153478L;

public QuicKeyUnavailableException(final String message, final KeySpace keySpace) {
super(Objects.requireNonNull(keySpace) + " keyspace: " + message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.internal.net.quic;

/**
* Supplies contextual 1-RTT information that's available in the QUIC implementation of the
* {@code java.net.http} module, to the QUIC TLS layer in the {@code java.base} module.
*/
public interface QuicOneRttContext {

/**
* {@return the largest packet number that was acknowledged by
* the peer in the 1-RTT packet space}
*/
long getLargestPeerAckedPN();
}
152 changes: 152 additions & 0 deletions src/java.base/share/classes/jdk/internal/net/quic/QuicTLSContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.internal.net.quic;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.Arrays;
import java.util.Objects;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLContextSpi;
import javax.net.ssl.SSLParameters;

import sun.security.ssl.QuicTLSEngineImpl;
import sun.security.ssl.SSLContextImpl;

/**
* Instances of this class act as a factory for creation
* of {@link QuicTLSEngine QUIC TLS engine}.
*/
public final class QuicTLSContext {

// In this implementation, we have a dependency on
// sun.security.ssl.SSLContextImpl. We can only support
// Quic on SSLContext instances created by the default
// SunJSSE Provider
private final SSLContextImpl sslCtxImpl;

/**
* {@return {@code true} if the given {@code sslContext} supports QUIC TLS, {@code false} otherwise}
* @param sslContext an {@link SSLContext}
*/
public static boolean isQuicCompatible(final SSLContext sslContext) {
boolean parametersSupported = isQuicCompatible(sslContext.getSupportedSSLParameters());
if (!parametersSupported) {
return false;
}
// horrible hack - what we do here is try and get hold of a SSLContext
// that has already been initialised and configured with the HttpClient.
// We see if that SSLContext is created using an implementation of
// sun.security.ssl.SSLContextImpl. Since there's no API
// available to get hold of that underlying implementation, we use
// MethodHandle lookup to get access to the field which holds that
// detail.
final Object underlyingImpl = CONTEXT_SPI.get(sslContext);
if (!(underlyingImpl instanceof SSLContextImpl ssci)) {
return false;
}
return ssci.isUsableWithQuic();
}

/**
* {@return {@code true} if protocols of the given {@code parameters} support QUIC TLS, {@code false} otherwise}
*/
public static boolean isQuicCompatible(SSLParameters parameters) {
String[] protocols = parameters.getProtocols();
return protocols != null && Arrays.asList(protocols).contains("TLSv1.3");
}

private static SSLContextImpl getSSLContextImpl(
final SSLContext sslContext) {
final Object underlyingImpl = CONTEXT_SPI.get(sslContext);
assert underlyingImpl instanceof SSLContextImpl;
return (SSLContextImpl) underlyingImpl;
}

/**
* Constructs a QuicTLSContext for the given {@code sslContext}
*
* @param sslContext The SSLContext
* @throws IllegalArgumentException If the passed {@code sslContext} isn't
* supported by the QuicTLSContext
* @see #isQuicCompatible(SSLContext)
*/
public QuicTLSContext(final SSLContext sslContext) {
Objects.requireNonNull(sslContext);
if (!isQuicCompatible(sslContext)) {
throw new IllegalArgumentException(
"Cannot construct a QUIC TLS context with the given SSLContext");
}
this.sslCtxImpl = getSSLContextImpl(sslContext);
}

/**
* Creates a {@link QuicTLSEngine} using this context
* <p>
* This method does not provide hints for session caching.
*
* @return the newly created QuicTLSEngine
*/
public QuicTLSEngine createEngine() {
return createEngine(null, -1);
}

/**
* Creates a {@link QuicTLSEngine} using this context using
* advisory peer information.
* <p>
* The provided parameters will be used as hints for session caching.
* The {@code peerHost} parameter will be used in the server_name extension,
* unless overridden later.
*
* @param peerHost The peer hostname or IP address. Can be null.
* @param peerPort The peer port, can be -1 if the port is unknown
Comment on lines +125 to +126
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that be the hostname in the URI, or in the AltService?
Maybe we could add an @apiNote here to clarify it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well the javadoc here was written to match the one on SSLContext#createSSLEngine. The peer information is used for caching, but it's also used in the SNI extension, so ideally users should use the URI address, not the alt service one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Maybe that would deserve a note - since with HTTP/3 we have potentially two addresses and two ports.

* @return the newly created QuicTLSEngine
*/
public QuicTLSEngine createEngine(final String peerHost, final int peerPort) {
return new QuicTLSEngineImpl(this.sslCtxImpl, peerHost, peerPort);
}

// This VarHandle is used to access the SSLContext::contextSpi
// field which is not publicly accessible.
// In this implementation, Quic is only supported for SSLContext
// instances whose underlying implementation is provided by a
// sun.security.ssl.SSLContextImpl
private static final VarHandle CONTEXT_SPI;
static {
try {
final MethodHandles.Lookup lookup =
MethodHandles.privateLookupIn(SSLContext.class,
MethodHandles.lookup());
final VarHandle vh = lookup.findVarHandle(SSLContext.class,
"contextSpi", SSLContextSpi.class);
CONTEXT_SPI = vh;
} catch (Exception x) {
throw new ExceptionInInitializerError(x);
}
}
}

Loading