Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 19, 2025

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 19, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 19, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 19, 2025

      My latest hands-on could be the best value AI laptop of the summer, but I still have questions

      May 19, 2025

      DOOM: The Dark Ages had the lowest Steam launch numbers in series history — Is it suffering from the ‘Game Pass Effect’?

      May 19, 2025

      Microsoft won’t be left exposed if something “catastrophic” happens to OpenAI — but may still be 3 to 6 months behind ChatGPT

      May 19, 2025

      Microsoft Copilot gets OpenAI’s GPT-4o image generation support — but maybe a day late and a dollar short for the hype?

      May 19, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      ES6: Set Vs Array- What and When?

      May 19, 2025
      Recent

      ES6: Set Vs Array- What and When?

      May 19, 2025

      Transform JSON into Typed Collections with Laravel’s AsCollection::of()

      May 19, 2025

      Deployer

      May 19, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      My latest hands-on could be the best value AI laptop of the summer, but I still have questions

      May 19, 2025
      Recent

      My latest hands-on could be the best value AI laptop of the summer, but I still have questions

      May 19, 2025

      DOOM: The Dark Ages had the lowest Steam launch numbers in series history — Is it suffering from the ‘Game Pass Effect’?

      May 19, 2025

      Microsoft won’t be left exposed if something “catastrophic” happens to OpenAI — but may still be 3 to 6 months behind ChatGPT

      May 19, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Step by step guide to secure JDBC SSL connection with Postgres in AWS Glue

    Step by step guide to secure JDBC SSL connection with Postgres in AWS Glue

    April 6, 2024

    Have you ever tried connecting a database to AWS Glue using a JDBC SSL encryption connection? It can be quite a puzzle. A few months ago, I faced this exact challenge. I thought it would be easy, but  I was wrong! When I searched for help online, I couldn’t find much useful guidance. So, I rolled up my sleeves and experimented until I finally figured it out.

    Now, I am sharing my learnings with you. In this blog, I’ll break down the steps in a clear, easy-to-follow way. By the end, you’ll know exactly how to connect your database to AWS Glue with SSL encryption. Let’s make this complex task a little simpler together.

    Before moving ahead let’s discuss briefly how SSL encryption works

    The client sends a connection request (Client Hello).
    The server responds, choosing encryption (Server Hello).
    The client verifies the server’s identity using its certificate and root certificate.
    Key exchange establishes a shared encryption key.
    Encrypted data exchanged securely.
    Client may authenticate with its certificate before encrypted data exchange.
    Connection terminates upon session end or timeout.

    Now you got basic understanding let’s continue to configure the Glue for SSL encryption.

    The steps above are the basic steps of SSL encryption process. Let’s us now discuss how to configure the AWS Glue for SSL encryption.Before we start the configuration process we need the following Formatting below

    1)Client Certificate

    2 Root Certificate

    3) Certificate Key

    into DER format. This is the format suitable for AWS glue.

    DER (Distinguished Encoding Rules) is a binary encoding format used in cryptographic protocols like SSL/TLS to represent and exchange data structures defined by ASN.1. It ensures unambiguous and minimal-size encoding of cryptographic data such as certificates.

    Here’s how you can do it for each component:

    1 .Client Certificate (PEM):

    This certificate is used by the client (in this case, AWS Glue) to authenticate itself to the server (e.g., another Database) during the SSL handshake. It includes the public key of the client and is usually signed by a trusted Certificate Authority (CA) or an intermediate CA.

    If your client certificate is not already in DER format, you can convert it using the OpenSSL command-line tool:

    openssl x509 -in client_certificate.pem -outform der -out client_certificate.der

    Replace client_certificate.pem with the filename of your client certificate in DER format, and client_certificate.der with the desired filename for the converted DER-encoded client certificate.

     

    2.Root Certificate (PEM):

    The root certificate belongs to the Certificate Authority (CA) that signed the server’s certificate (in this case, Postgre Database). It’s used by the client to verify the authenticity of the server’s certificate during the SSL.

    Convert the root certificate to DER format using the following command:

    openssl x509 -in root_certificate.pem -outform der -out root_certificate.der

    Replace root_certificate.pem with the filename of your root certificate in DER format, and root_certificate.der with the desired filename for the converted DER-encoded root certificate.

     

    3.Certificate Key (PKCS#8 PEM):

    This is the private key corresponding to the client certificate. It’s used to prove the ownership of the client certificate during the SSL handshake.

    Convert the certificate key to PKCS#8 PEM format using the OpenSSL command-line tool:

    openssl pkcs8 -topk8 -inform PEM -outform DER -in certificate_key.pem -out certificate_key.pk8 -nocrypt

    Replace certificate_key.pem with the filename of your certificate key in PEM format, and certificate_key.pk8 with the desired filename for the converted PKCS#8 PEM-encoded certificate key.

     

    Stored the above certificates and key to S3 bucket. We will need these certificates while configuring the AWS glue.

     

     

    To connect AWS Glue to a PostgreSQL database over SSL using PySpark, you’ll need to provide the necessary SSL certificates and configure the connection properly. Here’s an example PySpark script demonstrating how to achieve this:

    from pyspark.context import SparkContext
    from awsglue.context import GlueContext
    from pyspark.sql import SparkSession

    # Initialize Spark and Glue contexts
    sc = SparkContext()
    glueContext = GlueContext(sc)
    spark = glueContext.spark_session

    # Define PostgreSQL connection properties
    jdbc_url = “jdbc:postgresql://your_postgresql_host:5432/your_database”
    connection_properties = {
    “user”: “your_username”,
    “password”: “your_password”,
    “ssl”: “true”,
    “sslmode”: “verify-ca”, # SSL mode: verify-ca or verify-full
    “sslrootcert”: “s3://etl-test-bucket1/root_certificate.der”, # S3 Path to root certificate
    “sslcert”: “s3://etl-test-bucket1/client_certificate.der”, # S3 Path to client certificate
    “sslkey”: “s3://etl-test-bucket1/certificate_key.pk8” # S3 Path to client certificate key
    }

    # Load data from PostgreSQL table
    dataframe = spark.read.jdbc(url=jdbc_url, table=”your_table_name”, properties=connection_properties)

    # Perform data processing or analysis
    # For example:
    dataframe.show()

    # Stop Spark session
    spark.stop()

     

    Now inside your glue job click on Job details page and scroll down until you see Dependent JARs path and Referenced files path options. Under Dependent JARs path put location of S3  path where you stored the jar file and in Referenced files path add the S3 path of converted Client,Root and Key certificate separated by comma “,”

     

    Now Click on Save option and you are ready to Go

     

    This concludes the steps to configure secure JDBC Connection with DB in AWS Glue. To summarize, in this blog we:

    1)Explained how to SSL encryption can be used for secure data exchange between AWS Glue and your database(here Postgresql)

    2) The steps to configure SSL Encryption in AWS Glue to secure JDBC connection with a database

     

    You can read my other blogs here

    read more about AWS Glue

     

     

     

     

     

     

    Source: Read More 

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleResearchers from Zhipu AI and Tsinghua University Introduced the ‘Self-Critique’ pipeline: Revolutionizing Mathematical Problem Solving in Large Language Models
    Next Article How Are Generative Retrieval and Multi-Vector Dense Retrieval Related To Each Other?

    Related Posts

    Development

    February 2025 Baseline monthly digest

    May 19, 2025
    Artificial Intelligence

    Markus Buehler receives 2025 Washington Award

    May 19, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    North Korean Front Companies Impersonate U.S. IT Firms to Fund Missile Programs

    Development

    U.S. Government Releases New AI Security Guidelines for Critical Infrastructure

    Development

    Google’s Gemini can now erase watermaks, and it’s worryingly good at it

    Operating Systems

    Hamas-Affiliated WIRTE Employs SameCoin Wiper in Disruptive Attacks Against Israel

    Development

    Highlights

    Development

    From AI Threats to Strategic Defenses: Singapore’s Cybersecurity Journey in 2023

    July 30, 2024

    As we reflect on the Singapore cyber landscape of 2023, it’s evident that the year…

    The 17 best early anti-Prime Day deals: Best Buy, Walmart, Costco, and more

    July 5, 2024

    New Wi-Fi Vulnerability Enables Network Eavesdropping via Downgrade Attacks

    May 16, 2024

    Oversight at Scale Isn’t Guaranteed: MIT Researchers Quantify the Fragility of Nested AI Supervision with New Elo-Based Framework

    May 3, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.