Skip to content
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

SSLEngineWebSocketServerFactory allows more customization #839

Merged
merged 3 commits into from
Jan 22, 2019

Conversation

BroHammie
Copy link
Contributor

@BroHammie BroHammie commented Jan 7, 2019

Description

Introduces a new class SSLEngineWebSocketServerFactory that takes a SSLEngine as parameter allowing for more customization.

Related Issue

#838

Motivation and Context

Now I can create a WebSocketServerFactory with a SSLEngine that has NeedClientAuth set to true, thus making Server request a client certificate on connect.

How Has This Been Tested?

Created a TwoWaySSLServerExample(included in PR) that sets the value. Running wireshark with and without that flag set I can see a difference and the server sending a "client certificate request"

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

this(sslEngine, Executors.newSingleThreadScheduledExecutor());
}

private SSLEngineWebSocketServerFactory(SSLEngine sslEngine, ExecutorService exec) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there any specific reason why this constructor is private and not public?


@Override
public void close() {

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like DefaultSSLWebSocketServerFactory closes the executor service in it's close method. Maybe it should be done here as well.

Copy link
Collaborator

@marci4 marci4 Jan 9, 2019

Choose a reason for hiding this comment

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

maybe even extend from DefaultSSLWebSocketServerFactory?

Copy link
Collaborator

@marci4 marci4 left a comment

Choose a reason for hiding this comment

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

Could you please include a basic unit test?

@BroHammie
Copy link
Contributor Author

Comments addressed, simple unit test included.

*
* @param sslContext - can not be <code>null</code>
* @param executerService - can not be <code>null</code>
* @param sslParameters - sslParameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

sslParameters cannot be null, could you please adjust the JavaDoc

public ByteChannel wrapChannel(SocketChannel channel, SelectionKey key) throws IOException {
SSLEngine e = sslcontext.createSSLEngine();
e.setUseClientMode(false);
if (sslParameters != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

No check needed since we throw an IllegalArgumentException()

@marci4
Copy link
Collaborator

marci4 commented Jan 17, 2019

@BroHammie sorry for again requesting changes :(

Copy link
Collaborator

@marci4 marci4 left a comment

Choose a reason for hiding this comment

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

Looking good for me @PhilipRoman?

Copy link
Collaborator

@PhilipRoman PhilipRoman left a comment

Choose a reason for hiding this comment

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

👍

@marci4
Copy link
Collaborator

marci4 commented Jan 22, 2019

@BroHammie thank you again for your contribution!

@marci4 marci4 merged commit 94bd7df into TooTallNate:master Jan 22, 2019
@marci4 marci4 added this to the Release 1.4.0 milestone Jan 22, 2019
@marci4 marci4 removed the Server label Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants