SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Authenticate to SAP HANA Cloud using X.509

Complete the provided steps to configure an SAP HANA Cloud, SAP HANA database instance to accept a login using an X.509 certificate. Examples will be provided to connect from HDBSQL and a Node.js application on Microsoft Windows, Linux, or macOS.

Overview

🎓 intermediate 15 min. SAP HANA CloudSAP HANA Cloud SAP HANA DatabaseSAP HANASAP HANA Express EditionSqlIntermediateSecurity

You will learn

  • How to create a client X.509 certificate for a non-productive or demo system
  • How to configure SAP HANA Cloud to accept authentication requests using X.509
  • How to use the client certificate in HDBSQL
  • How to use the client certificate in a Node.js application
Unknown U Unknown May 1, 2026
Created by February 8, 2023
Contributors

Prerequisites

Prerequisites

  • Access to and administrative rights to an SAP HANA Cloud instance such as a free-tier or trial account
  • The SAP HANA Client installed on Microsoft Windows, Linux, or macOS
  • An installation of Node.js

Steps

Intro

As described at User Authentication Mechanisms, there are multiple methods to authenticate a user when connecting to an SAP HANA Cloud database. A very common mechanism is a user name and password. This tutorial demonstrates X.509 Certificate-Based User Authentication.

X.509 certificates can be generated with a user supplied validity period, in addition to not being prone to phishing attacks. They can also be used in single sign-on environments and for technical users. A self-signed certificate authority will be created and used to sign a client certificate. An SAP HANA instance will be configured to trust certificates signed by the certificate authority. On authentication, the provided client certificate is matched to a database user.


Step 1 Setup

The SAP HANA Client can use different cryptographic service providers on the operating systems shown below.

Note: these steps will vary slightly depending on the operating system and security library used.

Operating SystemSecurity LibraryX.509 Support
Microsoft WindowsSAP Cryptographic LibraryYes
Microsoft WindowsMSCryptoNo
LinuxOpenSSLYes
LinuxSAP Cryptographic LibraryYes
macOSLibreSSLYes
macOSSAP Cryptographic LibraryYes

As a first step, we will ensure that basic connectivity is working with a user name and password. The steps below check the version of the SAP HANA Client, create a test user, and attempt to connect using basic authentication with mscrypto or OpenSSL. The SQL commands can be run by an admin user such as DBADMIN in the SQL console or hdbsql.

  1. Check the version of SAP HANA Client on your machine and ensure it is a recent release.

    Shell
    hdbsql -v 

    hdbsql version
    hdbsql version

  2. Go to HANA Cloud Central and open a SQL console for your SAP HANA instance.

    Open SQL console in HCC
    Open SQL console in HCC

    Execute the following SQL to create a user to attempt to connect with.

    SQL
    CREATE USER TESTUSER PASSWORD Password1 NO FORCE_FIRST_PASSWORD_CHANGE SET USERGROUP DEFAULT;

    Create a test user in the SAP HANA database explorer
    Create a test user in the SAP HANA database explorer

  3. Attempt to connect with hdbsql using basic authentication. Be sure to replace the SQL endpoint value with the SQL endpoint of your HANA instance.

    Shell
    hdbsql -j -A -sslprovider mscrypto -u TESTUSER -p Password1 -Z traceFile=stdout -Z traceOptions=debug=warning,flush=on -n xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.hana.trial-us10.hanacloud.ondemand.com:443 "SELECT CURRENT_USER, CURRENT_SCHEMA FROM DUMMY;"
    Shell
    hdbsql -j -A -sslprovider openssl -u TESTUSER -p Password1 -Z traceFile=stdout -Z traceOptions=debug=warning,flush=on -n xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.hana.trial-us10.hanacloud.ondemand.com:443 "SELECT CURRENT_USER, CURRENT_SCHEMA FROM DUMMY;"

    successful connection with user and password authentication
    successful connection with user and password authentication

Step 2 Create a demo certificate authority
+
Step 3 Create a client certificate
+
Step 4 Create a PEM and Personal Security Environment (PSE) file for the SAP HANA Client
+
Step 5 Add the demorootca.crt to the CERTIFICATES table
+
Step 6 Create an X.509 provider and Personal Security Environment (PSE)
+
Step 7 Create a database user
+
Step 8 Connect using the SAP HANA database explorer using an X.509 certificate
+
Step 9 Connect from a Linux or macOS Client with HDBSQL using X.509 and OpenSSL
+
Step 10 Connect from a Linux, macOS, or Microsoft Windows Client with HDBSQL using X.509 and SAP Cryptographic Library (CommonCryptoLib)
+
Step 11 Connect from a Node.js app using X.509 and OpenSSL or CommonCryptoLib
+
Step 12 Cleanup (optional)
+
Step 13 Knowledge check
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 13
1. Setup 2. Create a demo certificate authority 3. Create a client certificate 4. Create a PEM and Personal Security Environment (PSE) file for the SAP HANA Client 5. Add the demorootca.crt to the CERTIFICATES table 6. Create an X.509 provider and Personal Security Environment (PSE) 7. Create a database user 8. Connect using the SAP HANA database explorer using an X.509 certificate 9. Connect from a Linux or macOS Client with HDBSQL using X.509 and OpenSSL 10. Connect from a Linux, macOS, or Microsoft Windows Client with HDBSQL using X.509 and SAP Cryptographic Library (CommonCryptoLib) 11. Connect from a Node.js app using X.509 and OpenSSL or CommonCryptoLib 12. Cleanup (optional) 13. Knowledge check

Learn more →