-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-45408][CORE] Add RPC SSL settings to TransportConf #43220
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
88 changes: 88 additions & 0 deletions
88
common/network-common/src/test/java/TransportConfSuite.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,88 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.network; | ||
|
|
||
| import java.io.File; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| import org.apache.spark.network.util.TransportConf; | ||
| import org.apache.spark.network.ssl.SslSampleConfigs; | ||
|
|
||
| public class TransportConfSuite { | ||
|
|
||
| private TransportConf transportConf = | ||
| new TransportConf( | ||
| "shuffle", SslSampleConfigs.createDefaultConfigProviderForRpcNamespace()); | ||
|
|
||
| @Test | ||
| public void testKeyStorePath() { | ||
| assertEquals(new File(SslSampleConfigs.keyStorePath), transportConf.sslRpcKeyStore()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testPrivateKeyPath() { | ||
| assertEquals(new File(SslSampleConfigs.privateKeyPath), transportConf.sslRpcPrivateKey()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testCertChainPath() { | ||
| assertEquals(new File(SslSampleConfigs.certChainPath), transportConf.sslRpcCertChain()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testTrustStorePath() { | ||
| assertEquals(new File(SslSampleConfigs.trustStorePath), transportConf.sslRpcTrustStore()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testTrustStoreReloadingEnabled() { | ||
| assertFalse(transportConf.sslRpcTrustStoreReloadingEnabled()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOpenSslEnabled() { | ||
| assertFalse(transportConf.sslRpcOpenSslEnabled()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSslRpcEnabled() { | ||
| assertTrue(transportConf.sslRpcEnabled()); | ||
| } | ||
|
|
||
|
|
||
| @Test | ||
| public void testSslKeyStorePassword() { | ||
| assertEquals("password", transportConf.sslRpcKeyStorePassword()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSslKeyPassword() { | ||
| assertEquals("password", transportConf.sslRpcKeyPassword()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSslTrustStorePassword() { | ||
| assertEquals("password", transportConf.sslRpcTrustStorePassword()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSsltrustStoreReloadIntervalMs() { | ||
| assertEquals(10000, transportConf.sslRpctrustStoreReloadIntervalMs()); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically, there are two cases -
a) Use of signed certificates, which can be validated,
b) Use of self-signed certificates.
Given the configs documented here, how are we planning to support these ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We support both of these.
If you like to use the JDK SSL provider, we require a
keyStoreargument which takes in the key being used for the server, and thetrustStoreis used to verify the peer we talk to.If the openSSL provider is used, we require the
privateKeyandcertChainarguments which have similar purposes.You can look at the
SSLFactoryin the reference PR #42685 (I was going to put it up after this PR and another one) to see how it's used.The tests in the reference PR #42685 use self signed certificates and work fine.
Does that answer your question? Happy to clarify as needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so we are relying on the fact the if truststore is not specified, it implies self signed cert as we are going to bypass cert check.
That sounds fine to me given this is different from 'typical' usage where client is accepting server's cert and does not know if it will be trusted, or should bypass trust (if cert is trusted, use that - but if it no, should it still be trusted).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looking at it again, I want to make sure I am not missing something here.
Currently,
sslRpcEnabledAndKeysAreValidwill returnfalsewhen key store is specified, but trust store is not - and so ssl factory will benull.Within ssl factory, we do have code to handle the case of trust store being null resulting in accepting all server certs - but this will never get triggered since factory is null.
What am I missing here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not missing anything. Thank you for catching this. In my testing, I was using a trust store that accepts the self signed certificate and copied this check to make the branches similar. But in the JDK SSL provider case, we do not always need the trust store as you rightly pointed out, so I'm going to remove the check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, PTAL