You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by "smiklosovic (via GitHub)" <gi...@apache.org> on 2023/07/20 22:45:45 UTC

[GitHub] [cassandra] smiklosovic opened a new pull request, #2505: CASSANDRA-18624 various improvements

smiklosovic opened a new pull request, #2505:
URL: https://github.com/apache/cassandra/pull/2505

   Thanks for sending a pull request! Here are some tips if you're new here:
    
    * Ensure you have added or run the [appropriate tests](https://cassandra.apache.org/_/development/testing.html) for your PR.
    * Be sure to keep the PR description updated to reflect all changes.
    * Write your PR title to summarize what this PR proposes.
    * If possible, provide a concise example to reproduce the issue for a faster review.
    * Read our [contributor guidelines](https://cassandra.apache.org/_/development/index.html)
    * If you're making a documentation change, see our [guide to documentation contribution](https://cassandra.apache.org/_/development/documentation.html)
    
   Commit messages should follow the following format:
   
   ```
   <One sentence description, usually Jira title or CHANGES.txt summary>
   
   <Optional lengthier description (context on patch)>
   
   patch by <Authors>; reviewed by <Reviewers> for CASSANDRA-#####
   
   Co-authored-by: Name1 <email1>
   Co-authored-by: Name2 <email2>
   
   ```
   
   The [Cassandra Jira](https://issues.apache.org/jira/projects/CASSANDRA/issues/)
   
   


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272529029


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider

Review Comment:
   Matter of taste really. @michaelsembwever what do you think? I do not like the fact that we are explicitly depending on something "Amazon" in the config.. I know it might probably look like a weird reason though. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272656103


##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>

Review Comment:
   for now we need something as a default even if it doesn't successfully load the .so files. 
   
   that's why it's `! aarch64` (as confusing as that might first read.)
   
   let's add a comment explaining the contortion…



##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>

Review Comment:
   for now we need something as a default even if it doesn't successfully load the .so files. 
   
   that's why it's `! aarch64` (as confusing as that might first read.)
   
   let's add a comment explaining the contortion…



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271271036


##########
bin/cassandra.in.sh:
##########
@@ -86,9 +86,9 @@ JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
 operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
 corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
-corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
-if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
-  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/platform -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
+if [ -f "${CASSANDRA_HOME}/lib/platform/${corretto_lib}" ]; then
+  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/platform/$corretto_lib";

Review Comment:
   are we sure all distros have the `findutils` package installed ? 
   
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271406679


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.
+# If this provider fails it will fall back to the default crypto provider in the JRE.
+#
+# To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
+#
+# To bypass the installation of a crypto provider use NoOpCryptoProvider.
+#
+#crypto_provider:
+#  - class_name: org.apache.cassandra.security.DefaultCryptoProvider

Review Comment:
   We may probably rename that to `InBuiltJREProvider` beause `NoOpCryptoProvider` sounds like it does not "do crypto" at all ... 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270929265


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,15 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>

Review Comment:
   @xgerman There is a lot of instances this is happening in that file, if you look closed. If we fixed it just here, it would be inconsistent with everything else. I would rather dedicated a separate ticket for cleaning it all up in one shot. How does that sound to you?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272633934


##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>

Review Comment:
   My concern is about putting something in the classpath that doesn't match the architecture type, so even if the cassandra is able to handle this case it's good, but the other applications may not. 
   If you think this will work, let's resolve this comment, I just wanted to point out a potential problem, but in fact, it may not even exist :-)



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272550930


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1217,6 +1222,35 @@ public static void applySslContext()
         }
     }
 
+    public static void applyCryptoProvider()
+    {
+        if (conf.crypto_provider == null)
+            conf.crypto_provider = new ParameterizedClass(DefaultCryptoProvider.class.getName(), null);
+
+        if (conf.crypto_provider.parameters == null)
+            conf.crypto_provider.parameters = new HashMap<>();
+
+        if (conf.crypto_provider.class_name == null)
+            throw new ConfigurationException("Failed to initialize crypto provider, class_name cannot be null");
+
+        conf.crypto_provider.parameters.putIfAbsent(AbstractCryptoProvider.FAIL_ON_MISSING_PROVIDER_KEY, "false");
+
+        try
+        {
+            Class<?> cryptoProviderClass = Class.forName(conf.crypto_provider.class_name);
+            cryptoProvider = (AbstractCryptoProvider)cryptoProviderClass.getConstructor(Map.class).newInstance(conf.crypto_provider.parameters);
+            cryptoProvider.install();

Review Comment:
   I like the fact that this needs to be explicitly taken care of. I know it is probably overreach but installation might happen elsewhere over time, people can install / uninstall here and there. God know how this is going to be used. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272535329


##########
src/java/org/apache/cassandra/security/InBuiltJREProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public final class InBuiltJREProvider extends AbstractCryptoProvider
+{
+    public InBuiltJREProvider(Map<String, String> properties)
+    {
+        super(properties);
+    }
+
+    @Override
+    public String getProviderName()
+    {
+        return InBuiltJREProvider.class.getSimpleName();
+    }
+
+    @Override
+    public String getProviderClassAsString()
+    {
+        return InBuiltJREProvider.class.getName();
+    }
+
+    @Override
+    protected Runnable installator() throws Exception

Review Comment:
   good catch, as it is just returning Runnable, not necessary.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 Amazon Corretto Crypto Provider

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1276165826


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,14 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"/>
+        </copy>
+
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar" failonerror="false"/>
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar" failonerror="false"/>

Review Comment:
   Perhaps it would be better to just move these jars to the lib/{$platform} folder after they have been resolved and downloaded into the `jar` folder, no?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271271862


##########
bin/cassandra.in.sh:
##########
@@ -86,9 +86,9 @@ JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
 operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
 corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
-corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
-if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
-  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/platform -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"

Review Comment:
   a cleaner approach here without corretto specifics here and `corretto_lib_pattern`
   
   would be
   ```
   if [ -d "${CASSANDRA_HOME}/lib/${operating_system}" ]; then
     for jar in ${CASSANDRA_HOME}/lib/${operating_system}/*.jar ; then
       CLASSPATH="$CLASSPATH:${jar}"
     done
   fi
   ```
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271331071


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,30 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider for x86 architecture.

Review Comment:
   ```suggestion
   # which will install Amazon Correto Crypto Provider.
   ```



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272428184


##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>

Review Comment:
   Should we also add `<family>unix</family>`? This will look more correct even if we never run on other operating systems.
   Is the condition correct? Should we place here `x86_64` to avoid matching other types of `x86`? 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271285880


##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   cherry-pick this bad boy
   https://github.com/thelastpickle/cassandra/commit/58f5a9c04a3c32e5da5298de3638424614138f38 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#issuecomment-1646669401

   thanks @michaelsembwever , all suggestions will be applied. It seems like I fixed the tests as well!


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271406679


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.
+# If this provider fails it will fall back to the default crypto provider in the JRE.
+#
+# To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
+#
+# To bypass the installation of a crypto provider use NoOpCryptoProvider.
+#
+#crypto_provider:
+#  - class_name: org.apache.cassandra.security.DefaultCryptoProvider

Review Comment:
   We may probably rename that to `InBuiltJREProvider` beause `NoOpProvider` sounds like it does not "do crypto" at all ... 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271270432


##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   why was this re-introduced? 
   
   i'm also confused as to why the macro needed to be moved out… `resolver-init` defines a number of macros that are used in other places…
   
   



##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   why was this re-introduced? 
   
   i'm also confused as to why the macro needed to be moved out… `resolver-init` defines a number of macros that are used in other places…
   
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272552515


##########
src/java/org/apache/cassandra/security/InBuiltJREProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public final class InBuiltJREProvider extends AbstractCryptoProvider

Review Comment:
   It was called like that :D But we came to conclusion with Mick that _NoOpCryptoProvider_ sounds like you are going to use a provider which is _not doing any crypto at all_. Calling it like this means that you will get same crypto which is in JRE which is _doing some crypto_.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272542857


##########
test/distributed/org/apache/cassandra/distributed/impl/Instance.java:
##########
@@ -923,6 +923,8 @@ public Future<Void> shutdown(boolean graceful)
             
             error = parallelRun(error, executor, this::stopJmx);
 
+            DatabaseDescriptor.getCryptoProvider().uninstall();

Review Comment:
   If we catch it then what do you want to do with that ... to log it? So we do all the stuff but crypto provider will remain to be installed. Then on the next test this will fail horribly (been there, done that) because it will use old crypto provider with new classloader of new Instance. 
   
   I would rather throw this so people are aware of the fact that something strange is going on with their setup. Otherwise it is just lost somewhere as a log which is easily overlooked.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272694488


##########
test/distributed/org/apache/cassandra/distributed/impl/Instance.java:
##########
@@ -923,6 +923,8 @@ public Future<Void> shutdown(boolean graceful)
             
             error = parallelRun(error, executor, this::stopJmx);
 
+            DatabaseDescriptor.getCryptoProvider().uninstall();

Review Comment:
   @Mmuzaf yes that works! wrapping it in parallelRun, good catch.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271333498


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,30 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider for x86 architecture.
+#
+# If you are on a different architecture (e.g. aarch), startup scripts will automatically
+# detect this and aarch version of the library is used.
+#
+# If the resolution of the architecture is not successful, or it somehow fails,
+# the crypto provider is not installed and default, in-built, crypto provider in your JRE
+# will be used.
+#
+# If you want to fail the startup of a node if the provider was not installed properly,
+# you have to set property "fail_on_missing_provider" to "true" which is by default "false".
+# This property is not specific for DefaultCryptoProvider, it will be present to every provider with same logic.
+
+# To install custom provider, you need to extend org.apache.cassandra.security.AbstractCryptoProvider,
+# put it to class path and reference here to use it.
+#
+# If you want to completely bypass the installation of a crypto provider, please use NoOpCryptoProvider.

Review Comment:
   ```suggestion
   # Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.  If this provider fails it will fallback to the default crypto provider in the JRE.
   #
   # To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
   #
   # To bypass the installation of a crypto provider use NoOpCryptoProvider.
   ```
   
   my attempt at more concise and direct language. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271276802


##########
bin/cassandra.in.sh:
##########
@@ -86,9 +86,9 @@ JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
 operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
 corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
-corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
-if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
-  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/platform -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"

Review Comment:
   you mean rather this
   
       platform=$(uname -m)
       if [ -d "${CASSANDRA_HOME}/lib/${platform}" ]; then
         for jar in ${CASSANDRA_HOME}/lib/${platform}/*.jar ; do
           CLASSPATH="$CLASSPATH:${jar}"
         done
       fi



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271411278


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.
+# If this provider fails it will fall back to the default crypto provider in the JRE.
+#
+# To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
+#
+# To bypass the installation of a crypto provider use NoOpCryptoProvider.
+#
+#crypto_provider:
+#  - class_name: org.apache.cassandra.security.DefaultCryptoProvider

Review Comment:
   yes, that was how i was reading it… 



##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.
+# If this provider fails it will fall back to the default crypto provider in the JRE.
+#
+# To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
+#
+# To bypass the installation of a crypto provider use NoOpCryptoProvider.
+#
+#crypto_provider:
+#  - class_name: org.apache.cassandra.security.DefaultCryptoProvider

Review Comment:
   yes, that was how i was reading it… 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272550930


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1217,6 +1222,35 @@ public static void applySslContext()
         }
     }
 
+    public static void applyCryptoProvider()
+    {
+        if (conf.crypto_provider == null)
+            conf.crypto_provider = new ParameterizedClass(DefaultCryptoProvider.class.getName(), null);
+
+        if (conf.crypto_provider.parameters == null)
+            conf.crypto_provider.parameters = new HashMap<>();
+
+        if (conf.crypto_provider.class_name == null)
+            throw new ConfigurationException("Failed to initialize crypto provider, class_name cannot be null");
+
+        conf.crypto_provider.parameters.putIfAbsent(AbstractCryptoProvider.FAIL_ON_MISSING_PROVIDER_KEY, "false");
+
+        try
+        {
+            Class<?> cryptoProviderClass = Class.forName(conf.crypto_provider.class_name);
+            cryptoProvider = (AbstractCryptoProvider)cryptoProviderClass.getConstructor(Map.class).newInstance(conf.crypto_provider.parameters);
+            cryptoProvider.install();

Review Comment:
   I like the fact that this needs to be explicitly taken care of. I know it is probably overreach but installation might happen elsewhere over time, people can install / uninstall here and there. God knows how this is going to be used. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272548607


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.

Review Comment:
   Good idea but what if that project changes the name or something like that ... links tend to break.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272692000


##########
test/distributed/org/apache/cassandra/distributed/impl/Instance.java:
##########
@@ -923,6 +923,8 @@ public Future<Void> shutdown(boolean graceful)
             
             error = parallelRun(error, executor, this::stopJmx);
 
+            DatabaseDescriptor.getCryptoProvider().uninstall();

Review Comment:
   As a fix I was thinking about the following `error = parallelRun(error, executor, () -> DatabaseDescriptor.getCryptoProvider().uninstall());`, but I think as the uninstall is called only in tests it should be safe from all sides.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270927865


##########
bin/cassandra.in.sh:
##########
@@ -84,6 +84,12 @@ JAVA_AGENT="$JAVA_AGENT -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.2.jar"
 # Added sigar-bin to the java.library.path CASSANDRA-7838
 JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
+operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
+corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
+if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
+  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+fi

Review Comment:
   yes it is logged 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270930067


##########
.build/parent-pom-template.xml:
##########
@@ -239,6 +239,42 @@
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>
+        </os>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>software.amazon.cryptools</groupId>
+          <artifactId>AmazonCorrettoCryptoProvider</artifactId>
+          <classifier>linux-x86_64</classifier>
+          <version>2.2.0</version>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>aarch_64</id>
+      <activation>
+        <os>
+          <arch>aarch64</arch>
+        </os>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>software.amazon.cryptools</groupId>
+          <artifactId>AmazonCorrettoCryptoProvider</artifactId>
+          <classifier>linux-aarch_64</classifier>
+          <version>2.2.0</version>

Review Comment:
   same



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270668249


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,14 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"/>
+        </copy>
+
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar" failonerror="false"/>
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar" failonerror="false"/>

Review Comment:
   because when doing `ant jar`, since that dependency is in pom.xml, resolver will copy all libraries as dependencies to `libs`. But we are also copying x86 and aarch to `corretto` dir. So you would have there these files two times. 



##########
.build/build-resolver.xml:
##########
@@ -279,6 +288,15 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-linux.so"/>
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
+
+
+        <!-- Amazon Corretto Crypto Providers for various architectures -->
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   probably possible, yeah... 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270662625


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -39,11 +39,20 @@ public void installProvider()
     {
         try
         {
-            AmazonCorrettoCryptoProvider.install();
+            Class.forName("com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider");

Review Comment:
   @michaelsembwever then you would have a completely different implementation of `ICryptoProvider` which you reference in `crypto_provider`.
   
   I was thinking about abstracting this logic so the same pattern would be used, "Amazon provider" would just override few values, the class to load, how installation and check is going to look like, but otherwise it would be all same for all specific crypto providers. 
   
   It looks like
   
       crypto_provider:
           - class_name: abc
              parameters:
                 - a: b



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271280330


##########
bin/cassandra.in.sh:
##########
@@ -86,9 +86,9 @@ JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
 operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
 corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
-corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
-if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
-  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/platform -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"

Review Comment:
   yes :) 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271276567


##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   @michaelsembwever it didnt work :( I noticed that while doing build in circle. You can have another shot at that ... it just ... didnt download anything.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272552515


##########
src/java/org/apache/cassandra/security/InBuiltJREProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public final class InBuiltJREProvider extends AbstractCryptoProvider

Review Comment:
   It was called like that :D But we came to conclusion with Mick that _NoOpCryptoProvider_ sounds like you are going to use a provider which is _not doing any crypto at all_. Calling it like this means that you will get same crypto which is in JVM.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272627203


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.

Review Comment:
   This is up to you :-)
   I think if the link can save a user a few seconds, it's better to add it. In case it gets broken at some point in the future then we have an LHF for someone to fix.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272565412


##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>

Review Comment:
   What other types, like 32 bits? Does Cassandra even run on 32 bits anyway? I would just keep it like this.
   
   If we run this like ... on FreeBSD, it will put x86 lib on the class path, then it will try to load it and it will presumably fail and log will be printed.
   
   I do not think anybody will ever build Cassandra with Maven on FreeBSD or any other unix for that matter. Like ...why? People are going to at most run it (if even that) and they are covered already as they will have it in `lib/x86_64` or `lib/aarch64`. So them running Cassandra on these platforms will not have any library added to the class path and again this is catched by the exception handling we have in place for the provider.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272704922


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";

Review Comment:
   I was thinking of a simple fix that would allow us to disable a new crypto provider without having to update the configuration file itself, which might not be very fast in a production environment that usually requires additional coordination between teams. Both flags also look OK too, but all that is up to you. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272660839


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1217,6 +1222,35 @@ public static void applySslContext()
         }
     }
 
+    public static void applyCryptoProvider()
+    {
+        if (conf.crypto_provider == null)
+            conf.crypto_provider = new ParameterizedClass(DefaultCryptoProvider.class.getName(), null);
+
+        if (conf.crypto_provider.parameters == null)
+            conf.crypto_provider.parameters = new HashMap<>();
+
+        if (conf.crypto_provider.class_name == null)
+            throw new ConfigurationException("Failed to initialize crypto provider, class_name cannot be null");
+
+        conf.crypto_provider.parameters.putIfAbsent(AbstractCryptoProvider.FAIL_ON_MISSING_PROVIDER_KEY, "false");
+
+        try
+        {
+            Class<?> cryptoProviderClass = Class.forName(conf.crypto_provider.class_name);

Review Comment:
   classForName is fine



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic closed pull request #2505: CASSANDRA-18624 Amazon Corretto Crypto Provider

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic closed pull request #2505: CASSANDRA-18624 Amazon Corretto Crypto Provider
URL: https://github.com/apache/cassandra/pull/2505


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270646348


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -39,11 +39,20 @@ public void installProvider()
     {
         try
         {
-            AmazonCorrettoCryptoProvider.install();
+            Class.forName("com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider");

Review Comment:
   what if we want something completely different? (like we load other things…)



##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -39,11 +39,20 @@ public void installProvider()
     {
         try
         {
-            AmazonCorrettoCryptoProvider.install();
+            Class.forName("com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider");

Review Comment:
   what if we want something completely different? (like we load other things…)



##########
.build/parent-pom-template.xml:
##########
@@ -239,6 +239,40 @@
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>

Review Comment:
   how will this not be enabled when `aarch64` is …? (profiles are not exclusive)



##########
.build/parent-pom-template.xml:
##########
@@ -239,6 +239,40 @@
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>

Review Comment:
   how will this not be enabled when `aarch64` is …? (profiles are not exclusive)



##########
.build/build-resolver.xml:
##########
@@ -279,6 +288,15 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-linux.so"/>
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
+
+
+        <!-- Amazon Corretto Crypto Providers for various architectures -->
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   can we not resolve and pull by maven coordinates ? 



##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,14 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"/>
+        </copy>
+
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar" failonerror="false"/>
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar" failonerror="false"/>

Review Comment:
   why the two deletes? 



##########
.build/build-resolver.xml:
##########
@@ -279,6 +288,15 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-linux.so"/>
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
+
+
+        <!-- Amazon Corretto Crypto Providers for various architectures -->
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   can we not resolve and pull by maven coordinates ? 



##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,14 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"/>
+        </copy>
+
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar" failonerror="false"/>
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar" failonerror="false"/>

Review Comment:
   why the two deletes? 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270764539


##########
.build/build-resolver.xml:
##########
@@ -279,6 +288,15 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-linux.so"/>
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
+
+
+        <!-- Amazon Corretto Crypto Providers for various architectures -->
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   yes it's a pita.
   
   it is done like
   ```
   
           <resolve>
               <dependencies>
                   <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
                   <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
               </dependencies>
           </resolve>
   ```



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271271036


##########
bin/cassandra.in.sh:
##########
@@ -86,9 +86,9 @@ JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
 operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
 corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
-corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
-if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
-  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/platform -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
+if [ -f "${CASSANDRA_HOME}/lib/platform/${corretto_lib}" ]; then
+  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/platform/$corretto_lib";

Review Comment:
   are we sure all distros have the `findutils` package installed ? 
   
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270674571


##########
.build/parent-pom-template.xml:
##########
@@ -239,6 +239,40 @@
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>

Review Comment:
   yeah, we don't want to be playing around with profiles on the command line. 
   
   let's 
   ```
    <profiles>
       <profile>
         <id>x86_64</id>
         <activation>
           <os><arch>!aarch64</arch></os>
         </activation>
         <dependencies>
           <dependency>
             <groupId>software.amazon.cryptools</groupId>
             <artifactId>AmazonCorrettoCryptoProvider</artifactId>
             <classifier>linux-x86_64</classifier>
             <version>2.2.0</version>
           </dependency>
         </dependencies>
       </profile>
       <profile>
         <id>aarch_64</id>
         <activation>
           <os><arch>aarch64</arch></os>
         </activation>
         …
   ```
   
   and if `<os><arch>!aarch64</arch></os>` doesn't work, then `<property><os.arch>!amd64</os.arch></property >`



##########
.build/parent-pom-template.xml:
##########
@@ -239,6 +239,40 @@
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>

Review Comment:
   yeah, we don't want to be playing around with profiles on the command line. 
   
   let's 
   ```
    <profiles>
       <profile>
         <id>x86_64</id>
         <activation>
           <os><arch>!aarch64</arch></os>
         </activation>
         <dependencies>
           <dependency>
             <groupId>software.amazon.cryptools</groupId>
             <artifactId>AmazonCorrettoCryptoProvider</artifactId>
             <classifier>linux-x86_64</classifier>
             <version>2.2.0</version>
           </dependency>
         </dependencies>
       </profile>
       <profile>
         <id>aarch_64</id>
         <activation>
           <os><arch>aarch64</arch></os>
         </activation>
         …
   ```
   
   and if `<os><arch>!aarch64</arch></os>` doesn't work, then `<property><os.arch>!amd64</os.arch></property >`



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271277188


##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   @michaelsembwever 
   
   I am getting this
   
   _resolver-dist-lib_get_files:
       [retry] Attempt [0]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying...
       [retry] Attempt [0]: error occurred; retrying after 10 ms...
   
   _resolver-dist-lib_get_files:
       [retry] Attempt [0]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying after 10 ms...
   
   _resolver-dist-lib_get_files:
       [retry] Attempt [0]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying after 10 ms...
   
   _resolver-dist-lib_get_files:
       [retry] Attempt [0]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying...
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270755976


##########
.build/build-resolver.xml:
##########
@@ -279,6 +288,15 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-linux.so"/>
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
+
+
+        <!-- Amazon Corretto Crypto Providers for various architectures -->
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   @michaelsembwever look, I am not going to do this. This is hell in Ant ... The thing is that we need to check if a file is present locally and if it is not we are going to call mvn plugin which downloads it, I tried to add the target to that but the logic around it is just ... meh. This is super straightforward.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271333498


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,30 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider for x86 architecture.
+#
+# If you are on a different architecture (e.g. aarch), startup scripts will automatically
+# detect this and aarch version of the library is used.
+#
+# If the resolution of the architecture is not successful, or it somehow fails,
+# the crypto provider is not installed and default, in-built, crypto provider in your JRE
+# will be used.
+#
+# If you want to fail the startup of a node if the provider was not installed properly,
+# you have to set property "fail_on_missing_provider" to "true" which is by default "false".
+# This property is not specific for DefaultCryptoProvider, it will be present to every provider with same logic.
+
+# To install custom provider, you need to extend org.apache.cassandra.security.AbstractCryptoProvider,
+# put it to class path and reference here to use it.
+#
+# If you want to completely bypass the installation of a crypto provider, please use NoOpCryptoProvider.

Review Comment:
   ```suggestion
   # Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.  If this provider fails it will fallback to the default crypto provider in the JRE.
   #
   # To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
   #
   # To bypass the installation of a crypto provider use NoOpCryptoProvider.
   ```
   
   my attempt and more concise and direct language. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271331256


##########
src/java/org/apache/cassandra/security/NoOpCryptoProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public class NoOpCryptoProvider extends AbstractCryptoProvider

Review Comment:
   ```suggestion
   public final class NoOpCryptoProvider extends AbstractCryptoProvider
   ```
   
   i can't imagine any reason anyone would want to subclass this.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272660839


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1217,6 +1222,35 @@ public static void applySslContext()
         }
     }
 
+    public static void applyCryptoProvider()
+    {
+        if (conf.crypto_provider == null)
+            conf.crypto_provider = new ParameterizedClass(DefaultCryptoProvider.class.getName(), null);
+
+        if (conf.crypto_provider.parameters == null)
+            conf.crypto_provider.parameters = new HashMap<>();
+
+        if (conf.crypto_provider.class_name == null)
+            throw new ConfigurationException("Failed to initialize crypto provider, class_name cannot be null");
+
+        conf.crypto_provider.parameters.putIfAbsent(AbstractCryptoProvider.FAIL_ON_MISSING_PROVIDER_KEY, "false");
+
+        try
+        {
+            Class<?> cryptoProviderClass = Class.forName(conf.crypto_provider.class_name);

Review Comment:
   classForName is fine. I like the fact that people have to use constructor with parameters (as map). Otherwise they would not see so easily that it is configurable and we are passing some map to some method. Parameters in constructors are common pattern in Cassandra configuration on ParameterizedClass.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272570190


##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>
+        </os>
+      </activation>
+      <dependencies>

Review Comment:
   We have been there. The problem with dependency management is that it can not be specified in profiles. I mean, you can technically put it there but then it is not visible in the child, you can not reference that from there.
   
    If we put that to dependency management outside profiles in parent, then we can not switch between the platform specific dependencies.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272526572


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider
+{
+    public DefaultCryptoProvider(Map<String, String> args)
+    {
+        super(args);
+    }
+
+    @Override
+    public String getProviderName()
+    {
+        return AmazonCorrettoCryptoProvider.PROVIDER_NAME;
+    }
+
+    @Override
+    public String getProviderClassAsString()
+    {
+        return "com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider";

Review Comment:
   The reason it is `String` is that if it is not on the class path, then it would throw what ... `ClassNotFoundException`? So I made it String on purpose and I am using `Class.forName` (which can be changed to FBUtilities as you suggested)



##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (InBuiltJREProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        Throwable t = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());

Review Comment:
   why not



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272527055


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";

Review Comment:
   Seems like an overkill to me but why not.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272653346


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider
+{
+    public DefaultCryptoProvider(Map<String, String> args)
+    {
+        super(args);
+    }
+
+    @Override
+    public String getProviderName()
+    {
+        return AmazonCorrettoCryptoProvider.PROVIDER_NAME;
+    }
+
+    @Override
+    public String getProviderClassAsString()
+    {
+        return "com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider";

Review Comment:
   +1 for use of FBUtilities



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271329183


##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   That helped! Thank you.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270662625


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -39,11 +39,20 @@ public void installProvider()
     {
         try
         {
-            AmazonCorrettoCryptoProvider.install();
+            Class.forName("com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider");

Review Comment:
   @michaelsembwever then you would have a completely different implementation of `ICryptoProvider` which you reference in `crypto_provider`.
   
   I was thinking about abstracting this logic so the same pattern would be used, "Amazon provider" would just override few values, the class to load, how installation and check is going to look like, but otherwise it would be all same for all specific crypto providers. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271405035


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +
+                                        "The most probable cause is that Cassandra node is not running on the same architecture " +
+                                        "the provider library is for. Please place the architecture-specific library " +
+                                        "for %s to the classpath and try again. ",
+                                        getProviderName(),
+                                        getProviderClassAsString());
+            }
+        }
+        catch (ClassNotFoundException ex)
+        {
+            failureMessage = getProviderClassAsString() + " is not on the class path!";
+        }
+        catch (Exception e)
+        {
+            failureMessage = format("The installation of %s was not successful, reason: %s",
+                                    getProviderClassAsString(), e.getMessage());
+        }
+
+        if (failureMessage != null)
+            if (failOnMissingProvider)
+                throw new ConfigurationException(failureMessage);
+            else
+                logger.warn(failureMessage);

Review Comment:
   braces on the outer if ? 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271406084


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +
+                                        "The most probable cause is that Cassandra node is not running on the same architecture " +
+                                        "the provider library is for. Please place the architecture-specific library " +
+                                        "for %s to the classpath and try again. ",
+                                        getProviderName(),
+                                        getProviderClassAsString());
+            }
+        }
+        catch (ClassNotFoundException ex)
+        {
+            failureMessage = getProviderClassAsString() + " is not on the class path!";
+        }
+        catch (Exception e)
+        {
+            failureMessage = format("The installation of %s was not successful, reason: %s",
+                                    getProviderClassAsString(), e.getMessage());
+        }
+
+        if (failureMessage != null)
+            if (failOnMissingProvider)
+                throw new ConfigurationException(failureMessage);
+            else
+                logger.warn(failureMessage);

Review Comment:
   @michaelsembwever I am getting different opinion on this from different people. You say this, somebody else says that I either braces everywhere or no braces at all. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271406084


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +
+                                        "The most probable cause is that Cassandra node is not running on the same architecture " +
+                                        "the provider library is for. Please place the architecture-specific library " +
+                                        "for %s to the classpath and try again. ",
+                                        getProviderName(),
+                                        getProviderClassAsString());
+            }
+        }
+        catch (ClassNotFoundException ex)
+        {
+            failureMessage = getProviderClassAsString() + " is not on the class path!";
+        }
+        catch (Exception e)
+        {
+            failureMessage = format("The installation of %s was not successful, reason: %s",
+                                    getProviderClassAsString(), e.getMessage());
+        }
+
+        if (failureMessage != null)
+            if (failOnMissingProvider)
+                throw new ConfigurationException(failureMessage);
+            else
+                logger.warn(failureMessage);

Review Comment:
   @michaelsembwever I am getting different opinion on this from different people. You say this, somebody else says that either braces everywhere or no braces at all. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271406679


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.
+# If this provider fails it will fall back to the default crypto provider in the JRE.
+#
+# To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
+#
+# To bypass the installation of a crypto provider use NoOpCryptoProvider.
+#
+#crypto_provider:
+#  - class_name: org.apache.cassandra.security.DefaultCryptoProvider

Review Comment:
   We may probably rename that to `InBuiltJREProvider` because `NoOpCryptoProvider` sounds like it does not "do crypto" at all ... 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271405964


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.
+# If this provider fails it will fall back to the default crypto provider in the JRE.
+#
+# To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
+#
+# To bypass the installation of a crypto provider use NoOpCryptoProvider.
+#
+#crypto_provider:
+#  - class_name: org.apache.cassandra.security.DefaultCryptoProvider

Review Comment:
   what does one specific if they want only the default crypto provider in the JRE ?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272442467


##########
test/unit/org/apache/cassandra/security/CryptoProviderTest.java:
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static com.google.common.collect.ImmutableMap.of;
+import static java.lang.String.format;
+import static org.apache.cassandra.security.AbstractCryptoProvider.FAIL_ON_MISSING_PROVIDER_KEY;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.spy;
+
+public class CryptoProviderTest

Review Comment:
   I think we can add a test, that reads the configuration file something the same as the `cassandra-pem-sslcontextfactory.yaml` is used and check that `AmazonCorrettoCryptoProvider` is used in that case.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272652185


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.

Review Comment:
   I wont add it there. The link would be something for "ah it is this thing" rather than a link which is crucial for the configuration itself. There is plethora of cases where links like this might be added over all documentation. Are we going to add links to Facebook's Zstd so a user knows what Zstd is? etc etc 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272574806


##########
test/unit/org/apache/cassandra/security/CryptoProviderTest.java:
##########
@@ -0,0 +1,225 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static com.google.common.collect.ImmutableMap.of;
+import static java.lang.String.format;
+import static org.apache.cassandra.security.AbstractCryptoProvider.FAIL_ON_MISSING_PROVIDER_KEY;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.spy;
+
+public class CryptoProviderTest

Review Comment:
   The tests are checking already that the provider is installed. `testCryptoProviderInstallation` checks that, for example.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272622229


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider
+{
+    public DefaultCryptoProvider(Map<String, String> args)
+    {
+        super(args);
+    }
+
+    @Override
+    public String getProviderName()
+    {
+        return AmazonCorrettoCryptoProvider.PROVIDER_NAME;
+    }
+
+    @Override
+    public String getProviderClassAsString()
+    {
+        return "com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider";

Review Comment:
   I saw that the class already imports the `AmazonCorrettoCryptoProvider`, that's why suggested this change. If you want Strings then both `getProviderName` and `getProviderClassAsString` should be simple strings :-)



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272628725


##########
src/java/org/apache/cassandra/security/InBuiltJREProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public final class InBuiltJREProvider extends AbstractCryptoProvider

Review Comment:
   Naming is not my talent :-) so we can leave it as is.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270929265


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,15 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>

Review Comment:
   @xgerman There is a lot of instances of this happening in that file, if you look closer. If we fixed it just here, it would be inconsistent with everything else. I would rather dedicate a separate ticket for cleaning it all up in one shot. How does that sound to you?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271408332


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +

Review Comment:
   The assumption is that if it does not pass the healthcheck, it is not installed. So the provider which was there (the default one) has not changed, so the "fallback" is kind of automatic. We are not returning to anything per se.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271407063


##########
.build/build-resolver.xml:
##########
@@ -212,6 +212,26 @@
         </retry>
         <mkdir dir="${local.repository}/org/apache/cassandra/deps/sigar-bin"/>
         <mkdir dir="${build.lib}/sigar-bin"/>
+        <mkdir dir="${build.lib}/x86_64"/>
+        <mkdir dir="${build.lib}/aarch_64"/>

Review Comment:
   This should be changed to `aarch64` because that is the output of `uname -m` we try to match. I have a commit for that but it is not pushed yet because pushing would cancel the build in Circle I am running right now. Will do later.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271411034


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +
+                                        "The most probable cause is that Cassandra node is not running on the same architecture " +
+                                        "the provider library is for. Please place the architecture-specific library " +
+                                        "for %s to the classpath and try again. ",
+                                        getProviderName(),
+                                        getProviderClassAsString());
+            }
+        }
+        catch (ClassNotFoundException ex)
+        {
+            failureMessage = getProviderClassAsString() + " is not on the class path!";
+        }
+        catch (Exception e)
+        {
+            failureMessage = format("The installation of %s was not successful, reason: %s",
+                                    getProviderClassAsString(), e.getMessage());
+        }
+
+        if (failureMessage != null)
+            if (failOnMissingProvider)
+                throw new ConfigurationException(failureMessage);
+            else
+                logger.warn(failureMessage);

Review Comment:
   my understanding is no-braces is only when there is one line that idents at the next level (here there is two) 🤷 
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271411034


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +
+                                        "The most probable cause is that Cassandra node is not running on the same architecture " +
+                                        "the provider library is for. Please place the architecture-specific library " +
+                                        "for %s to the classpath and try again. ",
+                                        getProviderName(),
+                                        getProviderClassAsString());
+            }
+        }
+        catch (ClassNotFoundException ex)
+        {
+            failureMessage = getProviderClassAsString() + " is not on the class path!";
+        }
+        catch (Exception e)
+        {
+            failureMessage = format("The installation of %s was not successful, reason: %s",
+                                    getProviderClassAsString(), e.getMessage());
+        }
+
+        if (failureMessage != null)
+            if (failOnMissingProvider)
+                throw new ConfigurationException(failureMessage);
+            else
+                logger.warn(failureMessage);

Review Comment:
   my understanding is no-braces is only when there is one line that idents at the next level (here there is two)



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271411997


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +
+                                        "The most probable cause is that Cassandra node is not running on the same architecture " +
+                                        "the provider library is for. Please place the architecture-specific library " +
+                                        "for %s to the classpath and try again. ",
+                                        getProviderName(),
+                                        getProviderClassAsString());

Review Comment:
   ```suggestion
                   failureMessage = format("%s health check failed . " +
                                           "Check node's architecture (`uname -m`) is supported, see lib/<arch> subdirectories. The correct architecture-specific library " +
                                           "for %s needs to be on the classpath. ",
                                           getProviderName(),
                                           getProviderClassAsString());
   ```



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271412294


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +

Review Comment:
   I hardened this logic a bit. We may uninstall the provider in case it was installed but healthcheck has failed. There might be other crypto providers which do it differently than Corretto.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272538323


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -426,6 +429,8 @@ private static void applyAll() throws ConfigurationException
         //InetAddressAndPort cares that applySimpleConfig runs first
         applySSTableFormats();
 
+        applyCryptoProvider();

Review Comment:
   I dont know yet. Does client or tool do crypto? I think so ... like ... nodetool? But one should verify if the library is going to be on the class path the same way Cassandra's class path has it. I think that scripts are executed somehow differently and putting this on CP of every tooling is a little bit tricky. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272610533


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";

Review Comment:
   I don't insist, just have a concern if we are adding a crypto library from the classpath it could cause some problems for the tools/clients. Perhaps it is better not to override the flag itself, but to override the `class_name` with a system property, so that if something goes wrong we can disable the 'Amazon' dependency and reset it back to the default. Wdyt?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272670684


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";

Review Comment:
   @Mmuzaf btw why not to have both property for class as well as for that flag?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272666945


##########
src/java/org/apache/cassandra/security/InBuiltJREProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public final class InBuiltJREProvider extends AbstractCryptoProvider

Review Comment:
   sure, we can shorten to JREProvider



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] xgerman commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "xgerman (via GitHub)" <gi...@apache.org>.
xgerman commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270864131


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,15 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>

Review Comment:
   don't like the hard coded 2.2.0 -- can't there be vars like in maven?



##########
.build/parent-pom-template.xml:
##########
@@ -239,6 +239,42 @@
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>
+        </os>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>software.amazon.cryptools</groupId>
+          <artifactId>AmazonCorrettoCryptoProvider</artifactId>
+          <classifier>linux-x86_64</classifier>
+          <version>2.2.0</version>

Review Comment:
   make 2.20 a variable to configure in one place



##########
.build/parent-pom-template.xml:
##########
@@ -770,6 +806,13 @@
       </dependency>
       <!-- end of chronicle-queue -->
 
+      <dependency>
+        <groupId>software.amazon.cryptools</groupId>
+        <artifactId>AmazonCorrettoCryptoProvider</artifactId>
+        <version>2.2.0</version>

Review Comment:
   same



##########
.build/parent-pom-template.xml:
##########
@@ -239,6 +239,42 @@
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>
+        </os>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>software.amazon.cryptools</groupId>
+          <artifactId>AmazonCorrettoCryptoProvider</artifactId>
+          <classifier>linux-x86_64</classifier>
+          <version>2.2.0</version>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
+      <id>aarch_64</id>
+      <activation>
+        <os>
+          <arch>aarch64</arch>
+        </os>
+      </activation>
+      <dependencies>
+        <dependency>
+          <groupId>software.amazon.cryptools</groupId>
+          <artifactId>AmazonCorrettoCryptoProvider</artifactId>
+          <classifier>linux-aarch_64</classifier>
+          <version>2.2.0</version>

Review Comment:
   same



##########
bin/cassandra.in.sh:
##########
@@ -84,6 +84,12 @@ JAVA_AGENT="$JAVA_AGENT -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.2.jar"
 # Added sigar-bin to the java.library.path CASSANDRA-7838
 JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
+operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
+corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
+if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
+  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+fi

Review Comment:
   maybe an else to print a warning that the other architetcure (e.g. MIPS, power. or whatever) is not supported



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272251148


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (InBuiltJREProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        Throwable t = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());

Review Comment:
   I have seen a lot of cases using the following `FBUtilities#classForName` I think here is a good place for that as well. It also throws `ConfigurationException` which is good for us.



##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";

Review Comment:
   I would also expose this property to the `CassandraRelevantProperties`, so that we can easily override it if necessary.



##########
test/distributed/org/apache/cassandra/distributed/impl/Instance.java:
##########
@@ -923,6 +923,8 @@ public Future<Void> shutdown(boolean graceful)
             
             error = parallelRun(error, executor, this::stopJmx);
 
+            DatabaseDescriptor.getCryptoProvider().uninstall();

Review Comment:
   The `uninstall' method throws a `SecurityException'. If an exception is thrown everything below is skipped. You handle this case in the `AbstractCryptoProvider`, but not for `Instance#shutdown(boolean)`. Is this correct?



##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.

Review Comment:
   I think it is worth adding a link to the project with documentation pages. Wdyt?
   https://github.com/corretto/amazon-corretto-crypto-provider



##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>

Review Comment:
   Should we also add `<family>unix</family>'? This will look more correct even if we never run on other operating systems.
   Is the condition correct? Should we place here `x86_64` to avoid matching other types of `x86`? 



##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>
+        </os>
+      </activation>
+      <dependencies>

Review Comment:
   This is the `cassandra-parent` pom, so it should probably be placed under the `<dependencyManagement>` section to avoid any problems for those projects that depend on this pom, but still don't want to see those dependencies in the classpath.
   The `<dependency>` probably should be used in the `cassandra-deps-template.xml` which defines the `cassandra-all` artifact. So, the question here is - is it safe putting this dependency in the classpath for all?



##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider
+{
+    public DefaultCryptoProvider(Map<String, String> args)
+    {
+        super(args);
+    }
+
+    @Override
+    public String getProviderName()
+    {
+        return AmazonCorrettoCryptoProvider.PROVIDER_NAME;
+    }
+
+    @Override
+    public String getProviderClassAsString()
+    {
+        return "com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider";

Review Comment:
   I think this should be `AmazonCorrettoCryptoProvider.PACKAGE_PREFIX + AmazonCorrettoCryptoProvider.PROVIDER_NAME` and placed as the class public constant. 



##########
src/java/org/apache/cassandra/security/InBuiltJREProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public final class InBuiltJREProvider extends AbstractCryptoProvider
+{
+    public InBuiltJREProvider(Map<String, String> properties)
+    {
+        super(properties);
+    }
+
+    @Override
+    public String getProviderName()
+    {
+        return InBuiltJREProvider.class.getSimpleName();
+    }
+
+    @Override
+    public String getProviderClassAsString()
+    {
+        return InBuiltJREProvider.class.getName();
+    }
+
+    @Override
+    protected Runnable installator() throws Exception

Review Comment:
   Neither implementation throws a checked exception, should we still keep the method signature as 'throws Exception`?



##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1500,6 +1534,15 @@ private static IFailureDetector createFailureDetector(String detectorClassName)
         return detector;
     }
 
+    public static AbstractCryptoProvider getCryptoProvider()
+    {
+        return cryptoProvider;
+    }
+
+    public static void setCryptoProvider(AbstractCryptoProvider cryptoProvider)

Review Comment:
   Do you think we need this method even if it is not used?



##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -426,6 +429,8 @@ private static void applyAll() throws ConfigurationException
         //InetAddressAndPort cares that applySimpleConfig runs first
         applySSTableFormats();
 
+        applyCryptoProvider();

Review Comment:
   Should it also be part of the tool initialisation and client initialisation? I'm referring to `toolInitialization` and `clientInitialization` methods.



##########
src/java/org/apache/cassandra/security/InBuiltJREProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public final class InBuiltJREProvider extends AbstractCryptoProvider

Review Comment:
   I would call it `NoOpCryptoProvider` instead, but it doesn't really matter.



##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1217,6 +1222,35 @@ public static void applySslContext()
         }
     }
 
+    public static void applyCryptoProvider()
+    {
+        if (conf.crypto_provider == null)
+            conf.crypto_provider = new ParameterizedClass(DefaultCryptoProvider.class.getName(), null);
+
+        if (conf.crypto_provider.parameters == null)
+            conf.crypto_provider.parameters = new HashMap<>();
+
+        if (conf.crypto_provider.class_name == null)
+            throw new ConfigurationException("Failed to initialize crypto provider, class_name cannot be null");
+
+        conf.crypto_provider.parameters.putIfAbsent(AbstractCryptoProvider.FAIL_ON_MISSING_PROVIDER_KEY, "false");
+
+        try
+        {
+            Class<?> cryptoProviderClass = Class.forName(conf.crypto_provider.class_name);

Review Comment:
   I think we can use `FBUtilities#classForName` here.
   OR
   alternatively use `FBUtilities#construct(java.lang.String, java.lang.String)` and pass the `ParameterizedClass` instance from the `config` directly to the `install` method.



##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1217,6 +1222,35 @@ public static void applySslContext()
         }
     }
 
+    public static void applyCryptoProvider()
+    {
+        if (conf.crypto_provider == null)
+            conf.crypto_provider = new ParameterizedClass(DefaultCryptoProvider.class.getName(), null);
+
+        if (conf.crypto_provider.parameters == null)
+            conf.crypto_provider.parameters = new HashMap<>();
+
+        if (conf.crypto_provider.class_name == null)
+            throw new ConfigurationException("Failed to initialize crypto provider, class_name cannot be null");
+
+        conf.crypto_provider.parameters.putIfAbsent(AbstractCryptoProvider.FAIL_ON_MISSING_PROVIDER_KEY, "false");
+
+        try
+        {
+            Class<?> cryptoProviderClass = Class.forName(conf.crypto_provider.class_name);
+            cryptoProvider = (AbstractCryptoProvider)cryptoProviderClass.getConstructor(Map.class).newInstance(conf.crypto_provider.parameters);
+            cryptoProvider.install();

Review Comment:
   In my humble opinion, it is good for the install method to only throw runtime exceptions, so we don't need to handle them here and they are passed directly to `CassandraDaemon#activate()` for handling. In fact, I have checked the `install()` method and it throws only runtime exceptions.



##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider

Review Comment:
   In my opinion, a better name would be `AmazonCorrettoCryptoProvider` or something like that, so that a user reading the configuration file can see exactly what the default provider is without having to go into the depths of the code.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#issuecomment-1648165596

   `CASSANDRA-18624 various improvements #2505` 
   The name of the pull request is a bit confusing :-)
   


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272653843


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider

Review Comment:
   🤷 
   



##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider

Review Comment:
   🤷 
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272698960


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -426,6 +429,8 @@ private static void applyAll() throws ConfigurationException
         //InetAddressAndPort cares that applySimpleConfig runs first
         applySSTableFormats();
 
+        applyCryptoProvider();

Review Comment:
   This is the hardest thing for me, so me neither. I need some time to get into the depths of the code to find a clear answer, so if we are trying to fit in release deadlines I would probably suggest adding this (or not) in another issue.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272698960


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -426,6 +429,8 @@ private static void applyAll() throws ConfigurationException
         //InetAddressAndPort cares that applySimpleConfig runs first
         applySSTableFormats();
 
+        applyCryptoProvider();

Review Comment:
   This is the hardest thing for me, so me neither. I need some time to get into the depths of the code to find a clear answer, so if we are trying to fit in release deadlines I would probably suggest adding this in another issue.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271406451


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +

Review Comment:
   Yes. And that happens if `fail_on_missing_provider` is `false`, if `true`, we fail the startup. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271405853


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +

Review Comment:
   is this the situation where the fallback to the JRE crypto provider happens?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271406530


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.
+# If this provider fails it will fall back to the default crypto provider in the JRE.
+#
+# To force failure when the provider was not installed properly, set the property "fail_on_missing_provider" to "true".
+#
+# To bypass the installation of a crypto provider use NoOpCryptoProvider.
+#
+#crypto_provider:
+#  - class_name: org.apache.cassandra.security.DefaultCryptoProvider

Review Comment:
   They use `NoOpCryptoProvider`.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272542857


##########
test/distributed/org/apache/cassandra/distributed/impl/Instance.java:
##########
@@ -923,6 +923,8 @@ public Future<Void> shutdown(boolean graceful)
             
             error = parallelRun(error, executor, this::stopJmx);
 
+            DatabaseDescriptor.getCryptoProvider().uninstall();

Review Comment:
   If we catch it then what do you want to do with that ... to log it? So we do all the stuff but crypto provider will remain to be installed. Then on the next test this will fail horribly (been there, done that) because it will use old crypto provider with new classloader of new Instance. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272654746


##########
src/java/org/apache/cassandra/security/InBuiltJREProvider.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+
+/**
+ * Crypto provider which does nothing. Handy for situations when a user
+ * wants to completely bypass crypto provider installation.
+ */
+public final class InBuiltJREProvider extends AbstractCryptoProvider

Review Comment:
   i'm leaning on `JREProvider` 
   
   NoOp means no crypto to me.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Mmuzaf commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "Mmuzaf (via GitHub)" <gi...@apache.org>.
Mmuzaf commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272616453


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider

Review Comment:
   This is up to you, just a minor suggestion :-)
   
   I also feel something strange seeing something non-cassandra in the config, do we need such configuration in the yaml? Are there any cons of just using a simple system property with the class name instead? 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 Amazon Corretto Crypto Provider

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1275844838


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1219,6 +1225,42 @@ public static void applySslContext()
         }
     }
 
+    public static void applyCryptoProvider()
+    {
+        if (TEST_SKIP_CRYPTO_PROVIDER_INSTALLATION.getBoolean())
+            return;
+
+        if (conf.crypto_provider == null)
+            conf.crypto_provider = new ParameterizedClass(DefaultCryptoProvider.class.getName(), null);

Review Comment:
   ```suggestion
           if (conf.crypto_provider == null)
               conf.crypto_provider = new ParameterizedClass(JREProvider.class.getName(), null);
   ```



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272652185


##########
conf/cassandra.yaml:
##########
@@ -1375,6 +1375,21 @@ dynamic_snitch_reset_interval: 600000ms
 # until the pinned host was 20% worse than the fastest.
 dynamic_snitch_badness_threshold: 1.0
 
+# Configures Java crypto provider. By default, it will use DefaultCryptoProvider
+# which will install Amazon Correto Crypto Provider.
+#
+# Amazon Correto Crypto Provider works currently for x86_64 and aarch_64 platforms.

Review Comment:
   I wont add it there. The link would be something for "ah it is this thing" rather than a link which is crucial for the configuration itself. There are plethora of cases where links like this might be added over all documentation. Are we going to add links to Facebook's Zstd so a user knows what Zstd is? etc etc 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270676140


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,14 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"/>
+        </copy>
+
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar" failonerror="false"/>
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar" failonerror="false"/>

Review Comment:
   cool.  add a comment please :) 
   
   
   and maybe… we need it in artifacts, not here… 🤷🏻‍♀️



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270676140


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,14 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"/>
+        </copy>
+
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar" failonerror="false"/>
+        <delete file="${build.lib}/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar" failonerror="false"/>

Review Comment:
   cool.  add a comment please :) 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] xgerman commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "xgerman (via GitHub)" <gi...@apache.org>.
xgerman commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270938184


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,15 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>

Review Comment:
   Sounds good to me. 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#issuecomment-1646123923

   @xgerman I removed the startup check logic and it is all installed as part of `appyCryptoProvider`. The reason behind this is that we should fail the start of the node as soon as possible.
   
   Also, there is Cassandra starting and somewhere down the road the check is executed as part of startup checks. However, while we start to assert the healthiness of the installation, cryptography might be already used by other parts of the code. Without the installation of the provider as soon as possible, we would end up in a situation when some parts of the code might use default crypto provider while other parts of the code Corretto one .... 
   
   cc @michaelsembwever 


-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270929265


##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,15 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>

Review Comment:
   @xgerman There is a lot of instances of this happening in that file, if you look closed. If we fixed it just here, it would be inconsistent with everything else. I would rather dedicated a separate ticket for cleaning it all up in one shot. How does that sound to you?



##########
.build/build-resolver.xml:
##########
@@ -246,6 +247,15 @@
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-linux.so"/>
             <file file="${local.repository}/org/apache/cassandra/deps/sigar-bin/libsigar-x86-solaris.so"/>
         </copy>
+
+        <copy todir="${build.lib}/corretto" quiet="true">
+            <file file="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"/>

Review Comment:
   @xgerman There is a lot of instances of this happening in that file, if you look closer. If we fixed it just here, it would be inconsistent with everything else. I would rather dedicated a separate ticket for cleaning it all up in one shot. How does that sound to you?



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271412524


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +
+                                        "The most probable cause is that Cassandra node is not running on the same architecture " +
+                                        "the provider library is for. Please place the architecture-specific library " +
+                                        "for %s to the classpath and try again. ",
+                                        getProviderName(),
+                                        getProviderClassAsString());
+            }
+        }
+        catch (ClassNotFoundException ex)
+        {
+            failureMessage = getProviderClassAsString() + " is not on the class path!";
+        }
+        catch (Exception e)
+        {
+            failureMessage = format("The installation of %s was not successful, reason: %s",
+                                    getProviderClassAsString(), e.getMessage());
+        }
+
+        if (failureMessage != null)
+            if (failOnMissingProvider)
+                throw new ConfigurationException(failureMessage);
+            else
+                logger.warn(failureMessage);

Review Comment:
   No worries I ll change that. I think that will be better, I am uncomfortable to have not have them there even it works ... 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271408784


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +

Review Comment:
   https://github.com/corretto/amazon-corretto-crypto-provider#verification-optional



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271411670


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());

Review Comment:
   ```suggestion
                   logger.info("{} health check ok", getProviderName());
   ```



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272720294


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";

Review Comment:
   added both



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272624590


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,171 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";

Review Comment:
   but that can not be added here because it is "too late" (e.g. in the constructor). We would need to do that in DatabaseDescriptor because that is the place where this class is instantiated.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271412524


##########
src/java/org/apache/cassandra/security/AbstractCryptoProvider.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cassandra.security;
+
+import java.security.Provider;
+import java.security.Security;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+
+import static java.lang.String.format;
+
+public abstract class AbstractCryptoProvider
+{
+    protected static final Logger logger = LoggerFactory.getLogger(AbstractCryptoProvider.class);
+    public static final String FAIL_ON_MISSING_PROVIDER_KEY = "fail_on_missing_provider";
+
+    protected final boolean failOnMissingProvider;
+
+    public AbstractCryptoProvider(Map<String, String> properties)
+    {
+        failOnMissingProvider = properties != null && Boolean.parseBoolean(properties.getOrDefault(FAIL_ON_MISSING_PROVIDER_KEY, "false"));
+    }
+
+    /**
+     * Returns name of the provider, as returned from {@link Provider#getName()}
+     *
+     * @return name of the provider
+     */
+    public abstract String getProviderName();
+
+    /**
+     * Returns the name of the class which installs specific provider of name {@link #getProviderName()}.
+     *
+     * @return name of class of provider
+     */
+    public abstract String getProviderClassAsString();
+
+    /**
+     * Returns a runnable which installs this crypto provider.
+     *
+     * @return runnable which installs this provider
+     */
+    protected abstract Runnable installator() throws Exception;
+
+    /**
+     * Returns boolean telling if this provider was installed properly.
+     *
+     * @return {@code true} if provider was installed properly, {@code false} otherwise.
+     */
+    protected abstract boolean isHealthyInstallation() throws Exception;
+
+    /**
+     * The default installation runs {@link AbstractCryptoProvider#installator()} and after that
+     * {@link AbstractCryptoProvider#isHealthyInstallation()}.
+     * <p>
+     * If any step fails, it will not throw an exception unless the parameter
+     * {@link AbstractCryptoProvider#FAIL_ON_MISSING_PROVIDER_KEY} is {@code true}.
+     */
+    public void install() throws Exception
+    {
+        if (NoOpCryptoProvider.class.getName().equals(getProviderClassAsString()))
+        {
+            logger.debug("Installation of a crypto provider was skipped.");
+            return;
+        }
+
+        String failureMessage = null;
+        try
+        {
+            Class.forName(getProviderClassAsString());
+
+            Provider[] providers = Security.getProviders();
+
+            if (providers.length > 0 && providers[0] != null && providers[0].getName().equals(getProviderName()))
+            {
+                logger.debug("{} was already installed", getProviderName());
+                return;
+            }
+            else
+            {
+                installator().run();
+            }
+
+            if (isHealthyInstallation())
+            {
+                logger.info("{} successfully passed the healthiness check", getProviderName());
+            }
+            else
+            {
+                failureMessage = format("%s is not the highest priority provider. " +
+                                        "The most probable cause is that Cassandra node is not running on the same architecture " +
+                                        "the provider library is for. Please place the architecture-specific library " +
+                                        "for %s to the classpath and try again. ",
+                                        getProviderName(),
+                                        getProviderClassAsString());
+            }
+        }
+        catch (ClassNotFoundException ex)
+        {
+            failureMessage = getProviderClassAsString() + " is not on the class path!";
+        }
+        catch (Exception e)
+        {
+            failureMessage = format("The installation of %s was not successful, reason: %s",
+                                    getProviderClassAsString(), e.getMessage());
+        }
+
+        if (failureMessage != null)
+            if (failOnMissingProvider)
+                throw new ConfigurationException(failureMessage);
+            else
+                logger.warn(failureMessage);

Review Comment:
   No worries I ll change that. I think that will be better, I am uncomfortable to not have them there even it works ... 
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272545163


##########
src/java/org/apache/cassandra/config/DatabaseDescriptor.java:
##########
@@ -1500,6 +1534,15 @@ private static IFailureDetector createFailureDetector(String detectorClassName)
         return detector;
     }
 
+    public static AbstractCryptoProvider getCryptoProvider()
+    {
+        return cryptoProvider;
+    }
+
+    public static void setCryptoProvider(AbstractCryptoProvider cryptoProvider)

Review Comment:
   Yes lets keep it there.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272644443


##########
src/java/org/apache/cassandra/security/DefaultCryptoProvider.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cassandra.security;
+
+import java.util.Map;
+import javax.crypto.Cipher;
+
+import com.amazon.corretto.crypto.provider.AmazonCorrettoCryptoProvider;
+
+/**
+ * Default crypto provider tries to install AmazonCorrettoCryptoProvider.
+ * <p>
+ * The implementation falls back to in-built crypto provider in JRE if the installation
+ * is not successful.
+ */
+public class DefaultCryptoProvider extends AbstractCryptoProvider

Review Comment:
   It is good as it is ... I wont change that.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1272570190


##########
.build/parent-pom-template.xml:
##########
@@ -233,12 +233,52 @@
       <id>zznate</id>
       <name>Nate McCall</name>
     </developer>
+    <developer>
+      <id>smiklosovic</id>
+      <name>Stefan Miklosovic</name>
+    </developer>
   </developers>
   <scm>
     <connection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</connection>
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <os>
+          <arch>!aarch64</arch>
+        </os>
+      </activation>
+      <dependencies>

Review Comment:
   We have been there. The problem with dependency management is that it can not be specified in profiles. If we put that to dependency management outside profiles in parent, then we can not switch between the platform specific dependencies.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270664989


##########
.build/parent-pom-template.xml:
##########
@@ -239,6 +239,40 @@
     <developerConnection>scm:https://gitbox.apache.org/repos/asf/cassandra.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf?p=cassandra.git;a=tree</url>
   </scm>
+
+  <profiles>
+    <profile>
+      <id>x86_64</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>

Review Comment:
   you would need to explicitly exclude it 
   
       mvn clean install -P !profile-to-exclude
   
   If we are scripting this, if there is a build machine on ARM, we would detect this and we would construct maven command which would exclude `x86_64`.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271271862


##########
bin/cassandra.in.sh:
##########
@@ -86,9 +86,9 @@ JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
 operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
 corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
-corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
-if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
-  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/platform -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"

Review Comment:
   a cleaner approach here without the corretto specifics here would be
   ```
   if [ -d "${CASSANDRA_HOME}/lib/${operating_system}" ]; then
     for jar in ${CASSANDRA_HOME}/lib/${operating_system}/*.jar ; then
       CLASSPATH="$CLASSPATH:${jar}"
     done
   fi
   ```
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1270879677


##########
bin/cassandra.in.sh:
##########
@@ -84,6 +84,12 @@ JAVA_AGENT="$JAVA_AGENT -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.2.jar"
 # Added sigar-bin to the java.library.path CASSANDRA-7838
 JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
+operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
+corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
+if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
+  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+fi

Review Comment:
   they are supported in the sense that it just falls back to normal provider.
   i'm guessing such feedback is provided from java logging at startup …? 



##########
bin/cassandra.in.sh:
##########
@@ -84,6 +84,12 @@ JAVA_AGENT="$JAVA_AGENT -javaagent:$CASSANDRA_HOME/lib/jamm-0.3.2.jar"
 # Added sigar-bin to the java.library.path CASSANDRA-7838
 JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
+operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
+corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
+if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
+  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+fi

Review Comment:
   they are supported in the sense that it just falls back to normal provider.
   i'm guessing such feedback is provided from java logging at startup …? 



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271277188


##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   @michaelsembwever 
   
   I am getting this
   
   _resolver-dist-lib_get_files:
       [retry] Attempt [0]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying...
       [retry] Attempt [0]: error occurred; retrying after 10 ms...
   
   _resolver-dist-lib_get_files:
       [retry] Attempt [0]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying after 10 ms...
   
   _resolver-dist-lib_get_files:
       [retry] Attempt [0]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying after 10 ms...
   
   _resolver-dist-lib_get_files:
       [retry] Attempt [0]: error occurred; retrying...
       [retry] Attempt [1]: error occurred; retrying...
       [retry] Attempt [2]: error occurred; retrying...
   
   ....
   
   /home/fermat/dev/cassandra/cassandra-instaclustr/cassandra/.build/build-resolver.xml:76: Task [resolver:resolve] failed after [3] attempts; giving up.
   Error messages:
   Reference all not found.
   Reference all not found.
   Reference all not found.
   Reference all not found.
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271276567


##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   @michaelsembwever it didnt work :( I noticed that while doing build in circle. You can have another shot at that ... it just ... didnt donwload anything.



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] smiklosovic commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "smiklosovic (via GitHub)" <gi...@apache.org>.
smiklosovic commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271276802


##########
bin/cassandra.in.sh:
##########
@@ -86,9 +86,9 @@ JAVA_OPTS="$JAVA_OPTS:-Djava.library.path=$CASSANDRA_HOME/lib/sigar-bin"
 
 operating_system=$(uname -s | tr '[:upper:]' '[:lower:]')
 corretto_lib_pattern="AmazonCorrettoCryptoProvider-*-$operating_system-$(uname -m).jar"
-corretto_lib="$(find "${CASSANDRA_HOME}"/lib/corretto -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"
-if [ -f "${CASSANDRA_HOME}/lib/corretto/${corretto_lib}" ]; then
-  CLASSPATH="$CLASSPATH${CASSANDRA_HOME}/lib/corretto/$corretto_lib";
+corretto_lib="$(find "${CASSANDRA_HOME}"/lib/platform -type f -name "$corretto_lib_pattern" -exec basename {} \; | head -n 1)"

Review Comment:
   you mean rather this
   
       platform=$(uname -m)
       if [ -d "${CASSANDRA_HOME}/lib/${platform}" ]; then
         for jar in ${CASSANDRA_HOME}/lib/${platform}/*.jar ; then
         CLASSPATH="$CLASSPATH:${jar}"
       done
     fi



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] michaelsembwever commented on a diff in pull request #2505: CASSANDRA-18624 various improvements

Posted by "michaelsembwever (via GitHub)" <gi...@apache.org>.
michaelsembwever commented on code in PR #2505:
URL: https://github.com/apache/cassandra/pull/2505#discussion_r1271280172


##########
.build/build-resolver.xml:
##########
@@ -290,13 +290,12 @@
             <url url="${lib.download.base.url}/lib/sigar-bin/libsigar-x86-solaris.so"/>
         </get>
 
-        <!-- Amazon Corretto Crypto Providers for various architectures -->
-        <resolve>
-            <dependencies>
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-x86_64" />
-                <dependency groupId="software.amazon.cryptools" artifactId="AmazonCorrettoCryptoProvider" version="2.2.0" classifier="linux-aarch_64" />
-            </dependencies>
-        </resolve>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-x86_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>
+        <get src="${artifact.github.release}/corretto/amazon-corretto-crypto-provider/releases/download/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             dest="${local.repository}/software/amazon/cryptools/AmazonCorrettoCryptoProvider/2.2.0/AmazonCorrettoCryptoProvider-2.2.0-linux-aarch_64.jar"
+             usetimestamp="true" quiet="true" skipexisting="true"/>

Review Comment:
   i'll take a look
   



-- 
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: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org