This repository was archived by the owner on Aug 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 889
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
7b8ce94
Added ExtendedSSLHandler to gracefully handle non ssl request
636125e
Merge branch 'staging_0_1_1' into issue_202
codinnvrends 12ebe49
formatted the java files
10c0bed
Merge branch 'issue_202' of https://github.com/pytorch/serve into iss…
7d4ad62
Merge branch 'staging_0_1_1' into issue_202
codinnvrends 4996b90
Fixed pmd error and added mar file cleanup
018ab48
Merge branch 'staging_0_1_1' into issue_202
codinnvrends 9a1a448
Merge branch 'staging_0_1_1' into issue_202
codinnvrends 75c4ad7
reverted to the change which was intended and mar file removal happen…
3038a6f
removed blank line
7d83769
Merge branch 'staging_0_1_1' into issue_202
harshbafna e4a8ea3
Merge branch 'master' into issue_202
codinnvrends d7edbc4
Merge branch 'master' into issue_202
codinnvrends 7b79e6b
Merge branch 'master' into issue_202
codinnvrends bbd8a66
Merge branch 'master' into issue_202
codinnvrends c7ea390
Merge branch 'master' into issue_202
codinnvrends bb31db6
Merge branch 'master' into issue_202
maaquib e1c97db
Merge branch 'master' into issue_202
harshbafna e006e89
Merge branch 'master' into issue_202
harshbafna c652fb4
Merge branch 'master' into issue_202
harshbafna 4ab1d77
fixed compilation issue
harshbafna ed30295
check if ssl enabled based on connector type
lxning 7646789
check if ssl enabled based on connector type
lxning 2d015d6
Merge branch 'master' into issue_202
lxning f0256a4
fmt
lxning c42586b
fix conflict
lxning 1898fd4
fix import order
lxning b4be92d
fmt
lxning 419d137
fmt ConfigManager.java
lxning d1dc90f
Merge branch 'master' into issue_202
maaquib 4917b80
Merge branch 'master' into issue_202
maaquib 5efea7f
Merge branch 'master' into issue_202
lxning File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
frontend/server/src/main/java/org/pytorch/serve/http/ExtendedSSLHandler.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package org.pytorch.serve.http; | ||
|
|
||
| import io.netty.buffer.ByteBuf; | ||
| import io.netty.channel.ChannelHandlerContext; | ||
| import io.netty.handler.codec.http.HttpResponseStatus; | ||
| import io.netty.handler.ssl.OptionalSslHandler; | ||
| import io.netty.handler.ssl.SslContext; | ||
| import io.netty.handler.ssl.SslHandler; | ||
| import java.util.List; | ||
| import org.pytorch.serve.util.ConfigManager; | ||
| import org.pytorch.serve.util.ConnectorType; | ||
| import org.pytorch.serve.util.NettyUtils; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class ExtendedSSLHandler extends OptionalSslHandler { | ||
| private static final Logger logger = LoggerFactory.getLogger(ExtendedSSLHandler.class); | ||
| /** the length of the ssl record header (in bytes) */ | ||
| private static final int SSL_RECORD_HEADER_LENGTH = 5; | ||
|
|
||
| private ConnectorType connectorType; | ||
|
|
||
| public ExtendedSSLHandler(SslContext sslContext, ConnectorType connectorType) { | ||
| super(sslContext); | ||
| this.connectorType = connectorType; | ||
| } | ||
|
|
||
| @Override | ||
| protected void decode(ChannelHandlerContext context, ByteBuf in, List<Object> out) | ||
| throws Exception { | ||
| if (in.readableBytes() < SSL_RECORD_HEADER_LENGTH) { | ||
| return; | ||
| } | ||
| ConfigManager configMgr = ConfigManager.getInstance(); | ||
| if (SslHandler.isEncrypted(in) || !configMgr.isSSLEnabled(connectorType)) { | ||
| super.decode(context, in, out); | ||
| } else { | ||
| logger.error("Recieved HTTP request!"); | ||
| NettyUtils.sendJsonResponse( | ||
| context, | ||
| new StatusResponse( | ||
| "This TorchServe instance only accepts HTTPS requests", | ||
| HttpResponseStatus.FORBIDDEN.code())); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.