You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "petrov-mg (via GitHub)" <gi...@apache.org> on 2023/07/13 13:06:25 UTC
[GitHub] [ignite] petrov-mg opened a new pull request, #10841: IGNITE-19975 Introduced abstract SSL Context Factory.
petrov-mg opened a new pull request, #10841:
URL: https://github.com/apache/ignite/pull/10841
Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
### The Contribution Checklist
- [ ] There is a single JIRA ticket related to the pull request.
- [ ] The web-link to the pull request is attached to the JIRA ticket.
- [ ] The JIRA ticket has the _Patch Available_ state.
- [ ] The pull request body describes changes that have been made.
The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
- [ ] The pull request title is treated as the final commit message.
The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
- [ ] A reviewer has been mentioned through the JIRA comments
(see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers))
- [ ] The pull request has been checked by the Teamcity Bot and
the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
### Notes
- [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
- [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
- [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
- [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] sonarcloud[bot] commented on pull request #10841: IGNITE-19975 Introduced abstract SSL Context Factory.
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #10841:
URL: https://github.com/apache/ignite/pull/10841#issuecomment-1635775434
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=10841)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_duplicated_lines_density&view=list)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] sonarcloud[bot] commented on pull request #10841: IGNITE-19975 Introduced abstract SSL Context Factory.
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #10841:
URL: https://github.com/apache/ignite/pull/10841#issuecomment-1634226053
SonarCloud Quality Gate failed. [](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=10841)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY) [2 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_duplicated_lines_density&view=list)
 Catch issues before they fail your Quality Gate with our IDE extension  [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=sonarcloud-welcome)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] sonarcloud[bot] commented on pull request #10841: IGNITE-19975 Introduced abstract SSL Context Factory.
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #10841:
URL: https://github.com/apache/ignite/pull/10841#issuecomment-1635481494
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=10841)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10841&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL) [1 Code Smell](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10841&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10841&metric=new_duplicated_lines_density&view=list)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] alex-plekhanov commented on a diff in pull request #10841: IGNITE-19975 Introduced abstract SSL Context Factory.
Posted by "alex-plekhanov (via GitHub)" <gi...@apache.org>.
alex-plekhanov commented on code in PR #10841:
URL: https://github.com/apache/ignite/pull/10841#discussion_r1263400720
##########
modules/core/src/main/java/org/apache/ignite/ssl/SslContextFactory.java:
##########
@@ -56,32 +48,18 @@
* // Rest of initialization.
* </pre>
*/
-public class SslContextFactory implements Factory<SSLContext> {
+public class SslContextFactory extends AbstractSslContextFactory {
/** */
private static final long serialVersionUID = 0L;
/** Default key / trust store type. */
public static final String DFLT_STORE_TYPE = System.getProperty("javax.net.ssl.keyStoreType", "JKS");
/** Default SSL protocol. */
- public static final String DFLT_SSL_PROTOCOL = "TLS";
-
- /**
- * Property name to specify default key/trust manager algorithm.
- *
- * @deprecated Use {@code "ssl.KeyManagerFactory.algorithm"} instead as per JSSE standard.
- *
- * Should be considered for deletion in 9.0.
- */
- @Deprecated
- public static final String IGNITE_KEY_ALGORITHM_PROPERTY = "ssl.key.algorithm";
Review Comment:
Don't forget to mention deletion of this property in release notes.
##########
modules/core/src/main/java/org/apache/ignite/ssl/AbstractSslContextFactory.java:
##########
@@ -0,0 +1,227 @@
+/*
+ * 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.ignite.ssl;
+
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.cache.configuration.Factory;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.util.typedef.internal.A;
+
+/**
+ * Represents abstract implementation of {@link Factory<SSLContext>} that caches the result of the first successful
+ * attempt to create an {@link SSLContext} and always returns it as a result of further invocations of the
+ * {@link SslContextFactory#create()}} method.
+ */
+public abstract class AbstractSslContextFactory implements Factory<SSLContext> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Default SSL protocol. */
+ public static final String DFLT_SSL_PROTOCOL = "TLS";
+
+ /** SSL protocol. */
+ protected String proto = DFLT_SSL_PROTOCOL;
+
+ /** Enabled cipher suites. */
+ protected String[] cipherSuites;
+
+ /** Enabled protocols. */
+ protected String[] protocols;
+
+ /** Cached instance of an {@link SSLContext}. */
+ protected final AtomicReference<SSLContext> sslCtx = new AtomicReference<>();
+
+ /**
+ * Gets protocol for secure transport.
+ *
+ * @return SSL protocol name.
+ */
+ public String getProtocol() {
+ return proto;
+ }
+
+ /**
+ * Sets protocol for secure transport. If not specified, {@link #DFLT_SSL_PROTOCOL} will be used.
+ *
+ * @param proto SSL protocol name.
+ */
+ public void setProtocol(String proto) {
+ A.notNull(proto, "proto");
+
+ this.proto = proto;
+ }
+
+ /**
+ * Sets enabled cipher suites.
+ *
+ * @param cipherSuites enabled cipher suites.
+ */
+ public void setCipherSuites(String... cipherSuites) {
+ this.cipherSuites = cipherSuites;
+ }
+
+ /**
+ * Gets enabled cipher suites.
+ *
+ * @return enabled cipher suites
+ */
+ public String[] getCipherSuites() {
+ return cipherSuites;
+ }
+
+ /**
+ * Gets enabled protocols.
+ *
+ * @return Enabled protocols.
+ */
+ public String[] getProtocols() {
+ return protocols;
+ }
+
+ /**
+ * Sets enabled protocols.
+ *
+ * @param protocols Enabled protocols.
+ */
+ public void setProtocols(String... protocols) {
+ this.protocols = protocols;
+ }
+
+ /**
+ * Creates SSL context based on factory settings.
+ *
+ * @return Initialized SSL context.
+ * @throws SSLException If SSL context could not be created.
+ */
+ private SSLContext createSslContext() throws SSLException {
+ checkParameters();
+
+ KeyManager[] keyMgrs = createKeyManagers();
+
+ TrustManager[] trustMgrs = createTrustManagers();
+
+ try {
+ SSLContext ctx = SSLContext.getInstance(proto);
+
+ if (cipherSuites != null || protocols != null) {
+ SSLParameters sslParameters = new SSLParameters();
+
+ if (cipherSuites != null)
+ sslParameters.setCipherSuites(cipherSuites);
+
+ if (protocols != null)
+ sslParameters.setProtocols(protocols);
+
+ ctx = new SSLContextWrapper(ctx, sslParameters);
+ }
+
+ ctx.init(keyMgrs, trustMgrs, null);
+
+ return ctx;
+ }
+ catch (NoSuchAlgorithmException e) {
+ throw new SSLException("Unsupported SSL protocol: " + proto, e);
+ }
+ catch (KeyManagementException e) {
+ throw new SSLException("Failed to initialized SSL context.", e);
+ }
+ }
+
+ /**
+ * @param param Value.
+ * @param name Name.
+ * @throws SSLException If {@code null}.
+ */
+ protected void checkNullParameter(Object param, String name) throws SSLException {
+ if (param == null)
+ throw new SSLException("Failed to initialize SSL context (parameter cannot be null): " + name);
+ }
+
+ /**
+ * Checks that all required parameters are set.
+ *
+ * @throws SSLException If any of required parameters is missing.
+ */
+ protected abstract void checkParameters() throws SSLException;
+
+ /**
+ * @return Created Key Managers.
+ * @throws SSLException If Key Managers could not be created.
+ */
+ protected abstract KeyManager[] createKeyManagers() throws SSLException;
+
+ /**
+ * @return Created Trust Managers.
+ * @throws SSLException If Trust Managers could not be created.
+ */
+ protected abstract TrustManager[] createTrustManagers() throws SSLException;
+
+ /**
+ * Disabled trust manager, will skip all certificate checks.
+ */
+ protected static class DisabledX509TrustManager implements X509TrustManager {
Review Comment:
Do we really need it in abstract class? It used only by SslContextFactory static method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ignite] petrov-mg merged pull request #10841: IGNITE-19975 Introduced abstract SSL Context Factory.
Posted by "petrov-mg (via GitHub)" <gi...@apache.org>.
petrov-mg merged PR #10841:
URL: https://github.com/apache/ignite/pull/10841
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org