Skip to content

Commit 9360540

Browse files
authored
Merge pull request #24 from FusionAuth/degroff/client-handshake-exception
Try and debug log more client exceptions
2 parents c7c2b4b + 75c1cfe commit 9360540

File tree

6 files changed

+52
-12
lines changed

6 files changed

+52
-12
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ To add this library to your project, you can include this dependency in your Mav
1212
<dependency>
1313
<groupId>io.fusionauth</groupId>
1414
<artifactId>java-http</artifactId>
15-
<version>0.3.3</version>
15+
<version>0.3.4</version>
1616
</dependency>
1717
```
1818

1919
If you are using Gradle, you can add this to your build file:
2020

2121
```groovy
22-
implementation 'io.fusionauth:java-http:0.3.3'
22+
implementation 'io.fusionauth:java-http:0.3.4'
2323
```
2424

2525
If you are using Savant, you can add this to your build file:
2626

2727
```groovy
28-
dependency(id: "io.fusionauth:java-http:0.3.3")
28+
dependency(id: "io.fusionauth:java-http:0.3.4")
2929
```
3030

3131
## Examples Usages:

build.savant

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jackson5Version = "3.0.1"
1717
restifyVersion = "4.2.1"
1818
testngVersion = "7.8.0"
1919

20-
project(group: "io.fusionauth", name: "java-http", version: "0.3.3", licenses: ["ApacheV2_0"]) {
20+
project(group: "io.fusionauth", name: "java-http", version: "0.3.4", licenses: ["ApacheV2_0"]) {
2121
workflow {
2222
fetch {
2323
// Dependency resolution order:

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>io.fusionauth</groupId>
44
<artifactId>java-http</artifactId>
5-
<version>0.3.3</version>
5+
<version>0.3.4</version>
66
<packaging>jar</packaging>
77

88
<name>Java HTTP library (client and server)</name>
@@ -178,4 +178,4 @@
178178
</build>
179179
</profile>
180180
</profiles>
181-
</project>
181+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2024, FusionAuth, All Rights Reserved
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the License.
15+
*/
16+
package io.fusionauth.http;
17+
18+
import javax.net.ssl.SSLException;
19+
20+
import io.fusionauth.http.server.HTTPS11Processor.HTTPSState;
21+
22+
/**
23+
* An SSLException that is most likely caused by the client.
24+
*
25+
* @author Daniel DeGroff
26+
*/
27+
public class ClientSSLHandshakeException extends SSLException {
28+
public ClientSSLHandshakeException(HTTPSState state, SSLException e) {
29+
super("An SSLException was thrown during a TLS handshake. HTTP processor state [" + state + "]", e);
30+
}
31+
}

src/main/java/io/fusionauth/http/server/HTTPS11Processor.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, FusionAuth, All Rights Reserved
2+
* Copyright (c) 2022-2024, FusionAuth, All Rights Reserved
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import java.nio.channels.SelectionKey;
2828
import java.security.GeneralSecurityException;
2929

30+
import io.fusionauth.http.ClientSSLHandshakeException;
3031
import io.fusionauth.http.ParseException;
3132
import io.fusionauth.http.log.Logger;
3233
import io.fusionauth.http.security.SecurityTools;
@@ -161,7 +162,11 @@ public ProcessorState read(ByteBuffer buffer) throws IOException {
161162
}
162163

163164
if (state == HTTPSState.HandshakeRead || state == HTTPSState.HandshakeWrite) {
164-
state = handshake();
165+
try {
166+
state = handshake();
167+
} catch (SSLException e) {
168+
throw new ClientSSLHandshakeException(state, e);
169+
}
165170

166171
if (handshakeData.hasRemaining()) {
167172
// This shouldn't happen, but let's resize just in case
@@ -271,7 +276,11 @@ public ByteBuffer[] writeBuffers() throws IOException {
271276
}
272277

273278
if (state == HTTPSState.HandshakeRead || state == HTTPSState.HandshakeWrite) {
274-
state = handshake();
279+
try {
280+
state = handshake();
281+
} catch (SSLException e) {
282+
throw new ClientSSLHandshakeException(state, e);
283+
}
275284
} else {
276285
encrypt();
277286
}

src/main/java/io/fusionauth/http/server/HTTPServerThread.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package io.fusionauth.http.server;
1717

18-
import javax.net.ssl.SSLHandshakeException;
1918
import java.io.Closeable;
2019
import java.io.IOException;
2120
import java.net.InetSocketAddress;
@@ -31,6 +30,7 @@
3130
import java.util.Map;
3231

3332
import io.fusionauth.http.ClientAbortException;
33+
import io.fusionauth.http.ClientSSLHandshakeException;
3434
import io.fusionauth.http.ParseException;
3535
import io.fusionauth.http.log.Logger;
3636
import io.fusionauth.http.util.ThreadPool;
@@ -171,8 +171,8 @@ public void run() {
171171
}
172172

173173
cancelAndCloseKey(key);
174-
} catch (ClientAbortException | SSLHandshakeException e) {
175-
// A client abort exception or SSLHandshakeException are common and should not be error logged.
174+
} catch (ClientAbortException | ClientSSLHandshakeException e) {
175+
// A client abort exception or client handshake exception are common and should not be error logged.
176176
logger.debug("A client related exception was thrown during processing", e);
177177
cancelAndCloseKey(key);
178178
} catch (Throwable t) {

0 commit comments

Comments
 (0)