GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — OpenSSL: Allow to obtain used named group via OpenSslSession · netty/netty@58d266f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • handler/src
    • main/java/io/netty/handler/ssl
      • ExtendedOpenSslSession.java
      • OpenSslSession.java
      • ReferenceCountedOpenSslEngine.java
    • test/java/io/netty/handler/ssl
      • PkiTestingTlsTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/ExtendedOpenSslSession.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/ExtendedOpenSslSession.java
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ public void handshakeFinished(byte[] id, String cipher, String protocol, byte[]
251251
wrapped.handshakeFinished(id, cipher, protocol, peerCertificate, peerCertificateChain, creationTime, timeout);
252252
}
253253

254+
@Override
255+
public String getNamedGroup() {
256+
return wrapped.getNamedGroup();
257+
}
258+
254259
@Override
255260
public boolean equals(Object o) {
256261
return wrapped.equals(o);
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/OpenSslSession.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/OpenSslSession.java
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public interface OpenSslSession extends SSLSession {
3434
*/
3535
boolean hasPeerCertificates();
3636

37+
/**
38+
* Returns the used named group or {@code null} if none was used or if it can't be determined.
39+
*
40+
* @return the named group
41+
*/
42+
default String getNamedGroup() {
43+
return null;
44+
}
45+
3746
@Override
3847
OpenSslSessionContext getSessionContext();
3948
}
Collapse file

‎handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java‎

Copy file name to clipboardExpand all lines: handler/src/main/java/io/netty/handler/ssl/ReferenceCountedOpenSslEngine.java
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,6 +2489,7 @@ private final class DefaultOpenSslSession implements OpenSslInternalSession {
24892489
// Updated once a new handshake is started and so the SSLSession reused.
24902490
private long lastAccessed = -1;
24912491

2492+
private volatile String namedGroup;
24922493
private volatile int applicationBufferSize = MAX_PLAINTEXT_LENGTH;
24932494
private volatile Certificate[] localCertificateChain;
24942495
private volatile Map<String, Object> keyValueStorage = new ConcurrentHashMap<String, Object>();
@@ -2653,7 +2654,11 @@ public void handshakeFinished(byte[] id, String cipher, String protocol, byte[]
26532654
}
26542655
this.cipher = toJavaCipherSuite(cipher, protocol);
26552656
this.protocol = protocol;
2656-
2657+
try {
2658+
this.namedGroup = SSL.getGroupName(ssl);
2659+
} catch (Exception e) {
2660+
throw new SSLException(e);
2661+
}
26572662
if (clientMode) {
26582663
if (isEmpty(peerCertificateChain)) {
26592664
peerCerts = EmptyArrays.EMPTY_CERTIFICATES;
@@ -2725,6 +2730,11 @@ private void initCerts(byte[][] chain, int startPos) {
27252730
}
27262731
}
27272732

2733+
@Override
2734+
public String getNamedGroup() {
2735+
return namedGroup;
2736+
}
2737+
27282738
@Override
27292739
public Certificate[] getPeerCertificates() throws SSLPeerUnverifiedException {
27302740
synchronized (ReferenceCountedOpenSslEngine.this) {
Collapse file

‎handler/src/test/java/io/netty/handler/ssl/PkiTestingTlsTest.java‎

Copy file name to clipboardExpand all lines: handler/src/test/java/io/netty/handler/ssl/PkiTestingTlsTest.java
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@
4040
import org.junit.jupiter.params.provider.ValueSource;
4141

4242
import java.util.ArrayList;
43+
import java.util.Arrays;
4344
import java.util.List;
4445
import java.util.concurrent.TimeUnit;
4546
import java.util.stream.Stream;
4647
import javax.net.ssl.SNIHostName;
4748
import javax.net.ssl.SSLParameters;
49+
import javax.net.ssl.SSLSession;
50+
51+
import static org.junit.jupiter.api.Assertions.assertTrue;
4852

4953
public class PkiTestingTlsTest {
5054

@@ -282,6 +286,19 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
282286
if (evt instanceof SslHandshakeCompletionEvent) {
283287
SslHandshakeCompletionEvent shce = (SslHandshakeCompletionEvent) evt;
284288
if (shce.isSuccess()) {
289+
SSLSession session = handler.engine().getSession();
290+
if (session instanceof OpenSslSession) {
291+
String namedGroup = ((OpenSslSession) handler.engine()
292+
.getSession()).getNamedGroup();
293+
if (groups != null) {
294+
assertTrue(Arrays.asList(groups).contains(namedGroup));
295+
} else {
296+
// If not specified explicit we will still use
297+
// what we can support.
298+
assertTrue(Arrays.asList(OpenSsl.NAMED_GROUPS)
299+
.contains(namedGroup));
300+
}
301+
}
285302
promise.setSuccess(shce);
286303
} else {
287304
promise.setFailure(shce.cause());

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.