<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: srikanth597</title>
    <description>The latest articles on DEV Community by srikanth597 (@srikanth597).</description>
    <link>https://dev.to/srikanth597</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F467945%2F7051caa5-4f14-4c74-8cfd-ba8dac004f0c.png</url>
      <title>DEV Community: srikanth597</title>
      <link>https://dev.to/srikanth597</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/srikanth597"/>
    <language>en</language>
    <item>
      <title>Securing AWS RDS Connections &amp; Updating SSL/TLS Certificates on Client Applications</title>
      <dc:creator>srikanth597</dc:creator>
      <pubDate>Wed, 21 Feb 2024 15:43:55 +0000</pubDate>
      <link>https://dev.to/srikanth597/securing-aws-rds-connections-updating-ssltls-certificates-on-client-applications-3gg5</link>
      <guid>https://dev.to/srikanth597/securing-aws-rds-connections-updating-ssltls-certificates-on-client-applications-3gg5</guid>
      <description>&lt;p&gt;Did you know AWS RDS 2019 CA is going to expire in August 2024, Let's find out how it's gonna impact you, what should be done &amp;amp; some important info on the right usage with examples. &lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction:
&lt;/h2&gt;

&lt;p&gt;AWS RDS (Relational Database Service) is a popular choice for businesses looking to streamline their data management needs, allowing them to scale and manage their databases easily. However, with the increasing number of cyber attacks, secure communication and data exchange have become of utmost importance. The SSL/TLS certificates play a crucial role in encrypting data, thus managing a secure connection between the client machine and the RDS Database. As the &lt;strong&gt;rds-ca-2019&lt;/strong&gt; certificate approaches its expiration in Aug 2024, it’s vital to renew it to ensure that data transmission between AWS RDS and client applications remains secure &amp;amp; avoid connectivity failures on the SSL Port after &lt;strong&gt;Aug 2024&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding SSL/TLS certificates for Databases:
&lt;/h2&gt;

&lt;p&gt;The SSL/TLS protocol ensures that data transmitted over a network is secure by encrypting it. There are two important things related to SSL/TLS certificates that users must understand when dealing with AWS RDS - authentication and encryption. The SSL/TLS certificates verify the authenticity of the server, thus ensuring clients connect to the right server, and also encrypt the data to protect it from unauthorized access. AWS RDS credentials, including SSL/TLS certificates, expire periodically, causing applications to stop working correctly or, worse, to be insecure.&lt;/p&gt;

&lt;p&gt;As per AWS recommendations, if your applications connect to an RDS instance using the SSL/TLS protocol, you need to renew the SSL/TLS certificate before August 2024, to prevent any connectivity issues. Renewing SSL/TLS certificates is a crucial process of maintaining a secure connection between your client applications and RDS instances as it verifies the authenticity of the server and encrypts data transmissions. Check &lt;a href="https://dev.to/srikanth597/tlsssl-tls-12-vs-13-2872"&gt;here&lt;/a&gt; if you want to know how SSL/TLS works&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1w7z0xvuozevlb6yheha.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1w7z0xvuozevlb6yheha.png" alt="Certs" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To renew the SSL/TLS certificate, on a high level you should follow the steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Update your client applications with the new SSL/TLS certificate. You can download the CA certificate from the RDS dashboard, and then update the trust stores on your client applications. This step is essential because the client application needs to trust the new CA to establish a secure connection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the SSL/TLS certificate on all affected database instances to the new ones that were issued. The current recommendation is to use &lt;code&gt;rds-ca-rsa2048-g1&lt;/code&gt; since it does not involve any algorithm changes. However, other CAs with new key algorithms are available, but it may take more time to test whether they work with your client setup.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; It's important to note that make your client changes first before any change on the RDS Database to provide backward compatibility &amp;amp; support the application.&lt;/p&gt;




&lt;h2&gt;
  
  
  Performing changes at client applications:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I am Considering the Java TechStack examples it will be mostly similar in other languages&lt;/p&gt;

&lt;p&gt;RDS Database: Postgres &amp;amp; Oracle&lt;br&gt;
Client Application: Java + Springboot&lt;br&gt;
Environment: Virtual machine &amp;amp; docker&lt;/p&gt;

&lt;p&gt;Load all Root CA certificates to Java TrustStore:&lt;/p&gt;

&lt;p&gt;There's a Root CA Certificate Bundle provided by AWS (Root Cert Bundle) which needs to be available on the client side to establish the SSL/TLS Session, however, out of the root bundle which contains all Region Certs, you can load only regions you are applications needs. For example, I am using &lt;strong&gt;us-west-2&lt;/strong&gt; &amp;amp; &lt;strong&gt;us-east-2&lt;/strong&gt; certificates as part of the trust store.&lt;/p&gt;

&lt;p&gt;Script to load the certs into the custom trust store:&lt;/p&gt;

&lt;p&gt;Create a trust store called &lt;strong&gt;&lt;code&gt;clientkeystore.jks&lt;/code&gt;&lt;/strong&gt; &amp;amp; load all available certs of the us-west-2 &amp;amp; us-east-2 region which includes &lt;strong&gt;&lt;code&gt;rds-ca-2019&lt;/code&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;code&gt;rds-ca-rsa2048-g1&lt;/code&gt;&lt;/strong&gt;, rds-ca-rsa4096-g1 and rds-ca-ecc384-g1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

#### filename: import_certs.sh

mydir=/usr/certs
if [ ! -e "${mydir}" ]
then
mkdir -p "${mydir}"
fi
truststore=${mydir}/clientkeystore.jks
storepassword=strongpassword

curl -sS "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" &amp;gt; ${mydir}/global-bundle.pem
awk 'split_after == 1 {n++;split_after=0} /-----END CERTIFICATE-----/ {split_after=1}{print &amp;gt; "rds-ca-" n ".pem"}' &amp;lt; ${mydir}/global-bundle.pem

for CERT in rds-ca-*; do
  alias=$(openssl x509 -noout -text -in $CERT | perl -ne 'next unless /Subject:/; s/.*(CN=|CN = )//; print')
  if echo $alias | grep -q "us-west-2\|us-east-2"; then
    echo "Importing $alias"
    keytool -import -file ${CERT} -alias "${alias}" -storepass ${storepassword} -keystore ${truststore} -noprompt
  fi
  rm $CERT
done

rm ${mydir}/global-bundle.pem

echo "Trust store content is: "

keytool -list -v -keystore "$truststore" -storepass ${storepassword} | grep Alias | cut -d " " -f3- | while read alias
do
   expiry=`keytool -list -v -keystore "$truststore" -storepass ${storepassword} -alias "${alias}" | grep Valid | perl -ne 'if(/until: (.*?)\n/) { print "$1\n"; }'`
   echo " Certificate ${alias} expires in '$expiry'"
done

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; We are loading these certs into the Custom Trust store, &amp;amp; NOT loading into the Java Default trust store i.e &lt;code&gt;${JAVA_HOME}/jre/lib/security/cacerts&lt;/code&gt;.  This is because in some cases will not be allowed to have write access into this System Trust Store in Certain Environments where Java is installed under the root user you may not have access to the changes to the default trust store, if not you can feel free to point the trust store location to default trust store.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Instructions&lt;/strong&gt; ( Optional if not using the dockerized environment) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM public.ecr.aws/amazoncorretto/amazoncorretto:17
........
COPY import_certs.sh /usr
RUN chmod +x /usr/import_certs.sh
# Import RDS certs for both west &amp;amp; east
RUN /usr/import_certs.sh
RUN chmod 644 /usr/certs/clientkeystore.jks
.........
.........
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;DataSource Changes&lt;/strong&gt; ( For SpringBoot based applications):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    @Bean("pgdataSource")
    public DataSource getDataSource() {
        DataSource postgresDataSource = null;
        try{
            LOGGER.debug("Configuring the dataSource with the configuration :: " +
                    "driver={}, url={}, userName={}, timeout={}, minIdle={} &amp;amp; maxPoolSize={}", dbDriver, dbUrl, dbUsername, connectionTimeout, minimumIdle, maximumPoolSize);
            HikariConfig config = new HikariConfig();
            config.setConnectionTimeout(connectionTimeout);
            config.setMinimumIdle(minimumIdle);
            config.setMaximumPoolSize(maximumPoolSize);
            config.setDriverClassName(dbDriver);
            config.setJdbcUrl(dbUrl);
            LOGGER.info("Postgres SSL Protocol isSSLEnabled : {}", isSSLEnabled);
            if(isSSLEnabled) {
                LOGGER.debug("Setting Truststore &amp;amp; root certificate");
                config.addDataSourceProperty(JAVAX_TRUST_STORE_TYPE_KEY, keyStoreType);
                config.addDataSourceProperty(JAVAX_TRUST_STORE_PATH_KEY, keyStoreFilePath);
                config.addDataSourceProperty(JAVAX_TRUST_STORE_PASSWORD_KEY, keyStoreFilePassword);
            }
            config.setUsername(dbUsername);
            config.setPassword(dbPassword);
            postgresDataSource = new HikariDataSource(config);
        }catch (Exception ex){
            LOGGER.error("exception while connecting to postgres database {}",ex);
            ex.printStackTrace();
        }
        return postgresDataSource;
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;JAVAX_TRUST_STORE_TYPE_KEY&lt;/code&gt; : &lt;code&gt;JKS&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;JAVAX_TRUST_STORE_PATH_KEY&lt;/code&gt; : &lt;code&gt;/usr/certs/clientkeystore.jks&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;JAVAX_TRUST_STORE_PASSWORD_KEY&lt;/code&gt; : &lt;code&gt;strongpassword&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The remaining should be DB user,password, URL etc pass it as per ur configurations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Plain Java Changes&lt;/strong&gt;(If springboot not used, follow similar style to this) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class PostgresConnection {
    public static void main(String[] args) {
        String dbURL = "jdbc:postgresql://mydb.123456789012.us-east-1.rds.amazonaws.com:5432/myrds?useSSL=true&amp;amp;sslmode=verify-ca&amp;amp;sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory";
        String username = "dbUser";
        String password = "******";

        try {
            // Class.forName("org.postgresql.Driver");
            Connection conn = DriverManager.getConnection(dbURL, username, password);
            if (conn != null) {
                System.out.println("Connected to PostgreSQL database");
            }
        } catch (SQLException ex) {
            System.out.println("Error: " + ex.getMessage());
        }
    }

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;You can Execute this way:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If Custom Truststore is used:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -cp /Users/drivers/postgresql-42.7.1.jar:./ -Djavax.net.ssl.trustStore=/usr/clientkeystore.jks -Djavax.net.ssl.trustStorePassword=strongpassword PostgresConnection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;If Default Java TrustStore used&lt;/strong&gt; (&lt;code&gt;${JAVA_HOME}/jre/lib/security/cacerts&lt;/code&gt;) :&lt;/p&gt;

&lt;p&gt;&lt;code&gt;java -cp /Users/drivers/postgresql-42.7.1.jar:./ PostgresConnection&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
PS: download the postgres jdbc driver &lt;a href="https://jdbc.postgresql.org/download"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OracleDriver example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are using the Oracle Driver &amp;amp; RDS Oracle Database, the setup will look mostly the same as the Postgres client, here's the example&lt;/p&gt;

&lt;p&gt;Springboot Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    @Bean("dataSource")
    @Primary
    public DataSource getDataSource() {
        DataSource hikariDataSource = null;
        HikariConfig config = new HikariConfig();
        config.setConnectionTimeout(connectionTimeout);
        config.setMinimumIdle(minimumIdle);
        config.setMaximumPoolSize(maximumPoolSize);
        config.setDriverClassName(dbDriver);
        config.setUsername(dbUsername);
        config.setPassword(dbPassword);

        if(isSSLEnabled) {
            config.setJdbcUrl(dbUrlTCPS);
            config.addDataSourceProperty(ORACLE_JDBC_COMPLIANT_KEY, ORACLE_JDBC_COMPLIANT);
            config.addDataSourceProperty(JAVAX_TRUST_STORE_TYPE_KEY, keyStoreType);
            config.addDataSourceProperty(JAVAX_TRUST_STORE_PATH_KEY, keyStoreFilePath);
            config.addDataSourceProperty(JAVAX_TRUST_STORE_PASSWORD_KEY, keyStoreFilePassword);
            config.addDataSourceProperty(ORACLE_DN_MATCH_KEY, sslDNMatch);
            hikariDataSource = new HikariDataSource(config);
            log.info("DB connection is established using SSL Protocol. Configuring the dataSource with the configuration :: " +
                            "driver={}, urlTCPS={}, userName={}, timeout={}, minIdle={} &amp;amp; maxPoolSize={}",
                    dbDriver, dbUrlTCPS, dbUsername, connectionTimeout, minimumIdle, maximumPoolSize);
        } else {
            config.setJdbcUrl(dbUrlTCP);
            hikariDataSource = new HikariDataSource(config);
            log.info("DB connection is established using NON-SSL Protocol. Configuring the dataSource with the configuration :: " +
                            "driver={}, urlTCP={}, userName={}, timeout={}, minIdle={} &amp;amp; maxPoolSize={}",
                    dbDriver, dbUrlTCP, dbUsername, connectionTimeout, minimumIdle, maximumPoolSize);
        }
        return hikariDataSource;
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plain Java Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;
import java.sql.*;
public class ConnectionTest {
    private static final String DB_SERVER_NAME = "db.mydbs32eds.us-west-2.rds.amazonaws.com";

    private static final Integer SSL_PORT = 15000;
    private static final String DB_SID = "some_sid";
    private static final String DB_USER = "someuser";
    private static final String DB_PASSWORD = "somepassword";
    // This key store has only the prod root ca.
    private static final String KEY_STORE_FILE_PATH = "/usr/clientkeystore.jks";
    private static final String KEY_STORE_PASS = "strongpassword";

    public static void main(String[] args) throws SQLException {
        final Properties properties = new Properties();

        final String connectionString = String.format("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=%s)(PORT=%d))"+"(CONNECT_DATA=(SERVICE_NAME=%s))"+"(SECURITY = (SSL_SERVER_CERT_DN = \"CN=%s, OU=RDS, O=Amazon.com, L=Seattle, ST=Washington, C=US\")))",DB_SERVER_NAME, SSL_PORT, DB_SID, DB_SERVER_NAME);

        try {
            // Class.forName("oracle.jdbc.driver.OracleDriver");
            properties.put("user", DB_USER);
            properties.put("password", DB_PASSWORD);
            properties.put("oracle.jdbc.J2EE13Compliant", "true");
            properties.put("javax.net.ssl.trustStore", KEY_STORE_FILE_PATH);
            properties.put("javax.net.ssl.trustStoreType", "JKS");
            properties.put("javax.net.ssl.trustStorePassword", KEY_STORE_PASS);
            properties.put("oracle.net.ssl_server_dn_match", "TRUE");
            final Connection con = DriverManager.getConnection(connectionString, properties);
            // If no exception, that means the handshake has passed, and an SSL connection can be opened

            if(con != null) {
                System.out.println("Connected to the database!");
            } else {
                System.out.println("Failed to make connection!");
            }
        }
        catch (Exception err) {
            System.out.println(err.${getMessage()});
        }
        finally {
            System.out.println("Connection closed");
            con.close();    //closing connection
        }      
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Client Connection Settings Review:
&lt;/h2&gt;

&lt;p&gt;Adding the SSL/TLS certificate to the trust store of your client application is not enough to ensure a secure environment. It's crucial to configure your connection string correctly for Postgres clients, especially the SSL modes. Using the right SSL modes and certificates when connecting to the database ensures that your communication is encrypted and authenticated, making it difficult for attackers to intercept and read your data. By specifying the SSL mode, SSL root certificate file, SSL cert file, and SSL key file in the connection string, you can ensure that your client application connects to the Postgres database securely. Ensure that you specify the right details and files in the connection string to protect your environment from cyber threats.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Postgres clients:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;when forming the Connection to the Postgres Database with the Certificate part of the Trust Store we are not proving it a secure environment, some of these settings will not be effective unless the connection string is formed correctly for Postgres clients, especially SSL modes.&lt;/p&gt;

&lt;p&gt;So let us review the Connection String which has been used in the above example.&lt;/p&gt;

&lt;p&gt;Postgres JDBC Connection String :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jdbc:postgresql://localhost:5432/db?useSSL=true&amp;amp;sslmode=verify-ca&amp;amp;sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;useSSL&lt;/strong&gt; : Ensures that the Client can make SSL Connections&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;sslfactory&lt;/code&gt;&lt;/strong&gt;: &lt;code&gt;org.postgresql.ssl.DefaultJavaSSLFactory&lt;/code&gt;
is specified in the JDBC URL because we want to avoid default LibPQ because it will deal with different implementations considering the use of the JKS truststore we can rely on JavaSSLFactory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sslmode&lt;/strong&gt;: SSLModes values will define the standard used when forming the SSL connection to the Database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Postgres SSL modes&lt;/strong&gt;: (ordered from least to most recommended)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;disable&lt;/code&gt; - disables SSL encryption completely.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;allow&lt;/code&gt; - allows SSL connections, but doesn't require it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;prefer&lt;/code&gt; - prefers SSL connection, but falls back to non-SSL if it fails.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;require&lt;/code&gt; - requires SSL connection, PostgreSQL will still establish an SSL connection, but it won't verify the server's certificate. This means that the server could potentially be an imposter, and your connection could be vulnerable to a man-in-the-middle (&lt;code&gt;MITM&lt;/code&gt;) attack.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;verify-ca&lt;/code&gt; - requires the SSL connection and verifies that the server certificate is issued by a trusted CA. Recommended only when you want to use the Route53 DNS record instead of the actual Postgres DNS record.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;verify-full&lt;/code&gt; - requires the SSL connection and verifies that the server certificate is issued by a trusted CA and hostname matches. (Most Recommended)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can see Sample Connection string that I used is the &lt;code&gt;verify-ca&lt;/code&gt;, I am not using &lt;code&gt;verify-full&lt;/code&gt; because the Host is &lt;code&gt;localhost&lt;/code&gt; which cannot be matched with the RDS Database hostname on the Certificate, that's because I am using port-forwarding instead of direct hostname.&lt;/p&gt;

&lt;p&gt;The best practice is to use the SSL mode &lt;code&gt;verify-full&lt;/code&gt; wherever possible, &lt;code&gt;verify-ca&lt;/code&gt; may still be used in cases where you would want to have a custom DNS record instead of a direct RDS Hostname DNS Record, even though this sacrifices the hostname check in proving the RDS Database Identity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Oracle Clients:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Oracle Clients have almost the same characteristics as Postgres clients do except SSL mode is strict TLS, unlike the different SSLMode in Postgres clients.&lt;/p&gt;

&lt;p&gt;Sample Oracle JDBC Connection String :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=%s)(PORT=%d))"+"(CONNECT_DATA=(SERVICE_NAME=%s))"+"(SECURITY = (SSL_SERVER_CERT_DN = \"CN=%s, OU=RDS, O=Amazon.com, L=Seattle, ST=Washington, C=US\")))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However the major difference is in Connection String, but when it comes to the Strict Hostname check Oracle Clients do have the same behavior as Postgres clients, where the Strict Hostname check can be relaxed with the property called &lt;code&gt;oracle.net.ssl_server_dn_match&lt;/code&gt;, the property can be toggled off when using the Custom DNS. But to prove the RDS Database Server Certificate to clients, it's always best to keep this property on &amp;amp; use the RDS Hostname directly.&lt;/p&gt;




&lt;p&gt;Conclusion:&lt;br&gt;
The SSL/TLS protocol plays a significant role in providing secure communication between client applications and RDS environments. Given the importance of RDS environments for businesses, it is vital to keep them secure. Since the 2019-ca SSL/TLS certificate is set to expire very soon, AWS RDS users need to renew their certificates. An outdated certificate may place your business data at risk of a cyber-attack. This post provides instructions for performing changes to client applications and also offers best practices to ensure strong SSL/TLS security when applications connect to Databases. By following these guidelines, AWS RDS Database Clients can keep their data transmission secure and continue to take advantage of the benefits of RDS environments.&lt;/p&gt;




&lt;p&gt;References:&lt;/p&gt;

&lt;p&gt;-&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://jdbc.postgresql.org/documentation/ssl/"&gt;https://jdbc.postgresql.org/documentation/ssl/&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL-certificate-rotation.html"&gt;https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL-certificate-rotation.html&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html"&gt;https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, please let me know your thoughts on this article, Your feedback is appreciated.&lt;/p&gt;

</description>
      <category>rds</category>
      <category>aws</category>
      <category>ssl</category>
      <category>java</category>
    </item>
    <item>
      <title>TLS(SSL) &amp; TLS 1.2 vs 1.3</title>
      <dc:creator>srikanth597</dc:creator>
      <pubDate>Mon, 02 Jan 2023 07:07:27 +0000</pubDate>
      <link>https://dev.to/srikanth597/tlsssl-tls-12-vs-13-2872</link>
      <guid>https://dev.to/srikanth597/tlsssl-tls-12-vs-13-2872</guid>
      <description>&lt;p&gt;Secure communication is one of the important aspects of the Data Transmission between 2 places, Almost all the web applications were using HTTPS/TLS layer transmission since long time, lets uncover how exactly does this Secure communication between client and server takes place using Handshake mechanism, and we will also algorithms that were typically used for this purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  TLS (Transport Layer Security):
&lt;/h2&gt;

&lt;p&gt;TLS is a Security protocol that is usually operated in OSI model between Layer 4(Transport) and Layer 7(Application). In simple terms it is responsible for the making the Encrypted communication between 2 sides.&lt;/p&gt;

&lt;p&gt;Both TLS 1.2 and 1.3 uses both Symmetric &amp;amp; Asymmetric Encryption mechanism for exchanging the information between client &amp;amp; server.&lt;br&gt;
Before we see the both algorithms in action lets understand what exactly is the Symmetric &amp;amp; Asymmetric Encryption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Symmetric Encryption :
&lt;/h2&gt;

&lt;p&gt;In Symmetric Encryption, the PlainText is Encrypted to CipherText using a single key, and CipherText can only be Decrypted back to PlainText using the same key that encrypted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Asymmetric Encryption :
&lt;/h2&gt;

&lt;p&gt;In Asymmetric Encryption, there will be 2 keys involved in the process which are mathematically related to each other(using Prime Numbers), where PlainText would be encrypted with one of the key usually referred to as Public Key. Combining the Plaintext with Public key provides the CipherText which will only be decrypted using the second key usually referred to as Private Key to get back the PlainText. &lt;/p&gt;

&lt;h2&gt;
  
  
  TLS 1.2 :
&lt;/h2&gt;

&lt;p&gt;In TLS 1.2 there is a lot of flexibility between Client &amp;amp; Server in choosing algorithm as encryption strategy. However this led to issues related to choosing weak algorithm in terms of security. We will take a look at this picture to see how it works.&lt;/p&gt;

&lt;p&gt;PS: I am ignoring the some of the information about CA (Certificate Authority) role in this context, in short it will be sending Digital Signature as part of the Certificate. Digital Signature is created with CA's private key, which will only be validated and trusted by CA's public key &amp;amp; corresponding algorithm that was sent in Certificate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frkfezbo5s0g5a26kr8u5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frkfezbo5s0g5a26kr8u5.png" alt="Image description" width="800" height="816"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following are steps that were followed like it was shown in the above picture.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When User enters &lt;em&gt;&lt;a href="https://testing.example.com" rel="noopener noreferrer"&gt;https://testing.example.com&lt;/a&gt;&lt;/em&gt; endpoint after DNS lookup it will try to establish TCP connection with the target &amp;amp; gets the acknowledgement.&lt;/li&gt;
&lt;li&gt;In the typical Asymmetric encryption the Key-Pair(public key&amp;amp; private key) is generated at the Server before it was registered with CA in the first place.&lt;/li&gt;
&lt;li&gt;Once Connection is established, Client sends an initialize Hello Message requesting Certificate which contains lot of information such as Validity, Issue of the certificate, Digital Signature  &amp;amp; Public Key of the Server.&lt;/li&gt;
&lt;li&gt;Once Client gets Public Key, it generates a temporary Session Key and encrypts this Session key with Public Key, and send this information to Server in the second round trip.&lt;/li&gt;
&lt;li&gt;When Server gets this encrypted data, it will only be decrypted using the Private Key of Key-Pair that was registered in the Asymmetric encryption.&lt;/li&gt;
&lt;li&gt;Once the Session key is available at the both ends, its ready for Secure communication between Client &amp;amp; server. From now on both ends will use this Session key as part of Symmetric Encryption to encrypt and decrypt the data between 2 ends.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TLS 1.3
&lt;/h2&gt;

&lt;p&gt;In TLS 1.3, with additional security in mind Servers will offer only a secure Algorithm as part of Key-Exchange Strategy and i.e Diffie-Hellman Algorithm, in this process it will also reduce one round-trip and optimises the whole process.&lt;/p&gt;

&lt;p&gt;First, We will understand the basics of the Diffie-Hellman Algorithm&lt;/p&gt;

&lt;p&gt;Using this algorithm there will be total of 3 different keys involved in Key-Exchange process, Combining all of the 3 will yield Session key. Result of combination any 2 of the 3 keys cannot be easily de-mystified to know what key's are being used in the process.&lt;/p&gt;

&lt;p&gt;It will make sense by looking at the implementation of the TLS 1.3.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bnrwcv58p3g0ddgd7yj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3bnrwcv58p3g0ddgd7yj.png" alt="Image description" width="800" height="790"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following are steps that were followed like it was shown in the above picture.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firstly, TCP connection gets established just like it happens in TLS 1.2&lt;/li&gt;
&lt;li&gt;Client will generate Key-Pair of Public &amp;amp; Private Key where Public Key and Private key will be combined together to get a secure temporary key which can't be tampered on the fly by anyone
(Here Public Key is GREEN, Private Key is BLUE -&amp;gt; generates secure key CYAN).&lt;/li&gt;
&lt;li&gt;Once secure temporary key is generated, both the secure temporary key &amp;amp; Public Key will be sent to Server.&lt;/li&gt;
&lt;li&gt;At server side combining the Private Key of the Server with the secure temporary key will yield the final Session key which will be used Symmetric Encryption
(Here secure temporary key is CYAN, Private Key of server is RED -&amp;gt; generates Session Key BROWN). &lt;/li&gt;
&lt;li&gt;In Response to this first round trip server will send back combination of Public Key of Client with Private Key of the server to Client
(Here Public Key is GREEN &amp;amp; Private Key is RED -&amp;gt; generates PURPLE key).&lt;/li&gt;
&lt;li&gt;This temporary key will be again combined with the initial secure temporary key to get the Session Key.
(Here temporary key is PURPLE &amp;amp; secure temporary key is CYAN -&amp;gt; generates Session Key BROWN).&lt;/li&gt;
&lt;li&gt;Once the Session key is available at the both ends, its ready for Secure communication between Client &amp;amp; server. From now on both ends will use this Session key as part of Symmetric Encryption to encrypt and decrypt the data between 2 ends.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;TLS is very important aspect in establishing the Secure communication, we have seen how exactly TLS communication is working behind the scenes. TLS 1.3 is latest protocol in optimising &amp;amp; reducing one round trip in establishing the Symmetric Encryption. &lt;/p&gt;

&lt;p&gt;I hope you guys enjoyed this article, please feel free to comment and share your thoughts.&lt;/p&gt;

</description>
      <category>api</category>
      <category>podcast</category>
      <category>techtalks</category>
    </item>
  </channel>
</rss>
