Encrypting Oracle Net Traffic Between Clouds: Native Network Encryption for Applications and Data Guard
Private connectivity between clouds, such as an OCI FastConnect link, Azure ExpressRoute or the OCI-Azure Interconnect, is often treated as if it were encryption. It is not: it keeps traffic off the public internet, but anything that can see packets on the path, including a misconfigured network appliance or a packet capture during troubleshooting, can read SQL text, bind values and result sets in clear text. Data Guard redo is the same: every change made on the primary crosses the link.
Oracle Net can encrypt and integrity-check that traffic itself, with a few lines in sqlnet.ora and no certificates. This post finds the unencrypted sessions, turns native network encryption on without a restart, moves safely from optional to mandatory, covers Data Guard in both directions, and explains when TLS is the better choice.
The Use Case
A primary database runs on an OCI virtual machine and its physical standby on Azure, with application servers in both clouds. A security review asks for all database traffic between the clouds to be encrypted and integrity-protected, using current algorithms, with evidence that no clear-text sessions remain.
Environment used in this runbook
Primary: SALES_OCI, Oracle Database 19c (19.24) on an OCI virtual machine, host sales-oci-db1
Standby: SALES_AZURE, Oracle Database 19c (19.24) on an Azure virtual machine, host sales-az-db1
Clients: Java applications with the 19c JDBC thin driver, and SQL*Plus with the 19c Instant Client
Network: private interconnect between OCI and Azure, Oracle Net on TCP port 1521
Licence: native network encryption and data integrity are included with every edition of Oracle Database; no extra option is needed
How Native Network Encryption Works
Negotiation at connect time. Client and server each declare whether encryption is REJECTED, ACCEPTED, REQUESTED or REQUIRED, and which algorithms they allow. The combination decides whether the session is encrypted, and with which algorithm.
Encryption protects confidentiality with AES. Use AES256; DES, 3DES and RC4 are deprecated in 19c and removed in 23ai.
Integrity (crypto-checksumming) detects modified or replayed packets. Use SHA256 or stronger; MD5 is deprecated in 19c and removed in 23ai.
The server reads sqlnet.ora at connection time. Changes apply to new connections immediately. Existing sessions keep what they negotiated.
Step 1: Check What Your Own Session Negotiated
V$SESSION_CONNECT_INFO lists the network services each session uses. Start with your own session over the network (not a local bequeath connection), so you see what a remote client sees.
SQL |
-- From a client host: sqlplus system@//sales-oci-db1.example.internal:1521/sales_app SELECT network_service_banner FROM v$session_connect_info WHERE sid = SYS_CONTEXT('USERENV', 'SID'); |
Expected output |
NETWORK_SERVICE_BANNER
--------------------------------------------------------------------------------
TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production
Encryption service for Linux: Version 19.0.0.0.0 - Production
Crypto-checksumming service for Linux: Version 19.0.0.0.0 - ProductionWhat to expect: The encryption and checksumming services are present, but no line names an algorithm such as "AES256 Encryption service adapter". That means the services were available and nothing was negotiated: this session is in clear text. When encryption is active, an extra adapter line names the algorithm.
Step 2: Count the Clear-Text Sessions Across the Cluster
Now look at every remote session. Group by machine and program, so you can tell application servers, tools and Data Guard apart.
SQL |
SELECT s.machine, s.program, COUNT(*) AS sessions FROM gv$session s WHERE s.type = 'USER' AND NOT EXISTS (SELECT 1 FROM gv$session_connect_info c WHERE c.inst_id = s.inst_id AND c.sid = s.sid AND c.serial# = s.serial# AND c.network_service_banner LIKE '%Encryption service adapter%') AND s.machine <> (SELECT host_name FROM v$instance) GROUP BY s.machine, s.program ORDER BY sessions DESC; |
Expected output |
MACHINE PROGRAM SESSIONS
-------------------- ------------------------------ ----------
app-oci-01 JDBC Thin Client 84
app-az-01 JDBC Thin Client 61
app-az-02 JDBC Thin Client 59
dba-jumphost sqlplus@dba-jumphost (TNS V1-V 3What to expect: Every remote user session that has not negotiated an encryption algorithm, grouped by where it comes from. Here all 207 remote sessions are clear text, including the 120 from Azure that cross the interconnect. Save this output: it is the "before" picture for the security review.
Step 3: Inspect the Server's sqlnet.ora
The server-side settings live in sqlnet.ora in the database home's network/admin directory (or in the directory TNS_ADMIN points to). Check what is there before you change anything, and keep a copy.
Shell |
cd $ORACLE_HOME/network/admin cp -p sqlnet.ora sqlnet.ora.$(date +%Y%m%d) grep -Ei 'ENCRYPTION|CRYPTO_CHECKSUM|ALLOW_WEAK' sqlnet.ora || echo "no network encryption settings" |
Expected output |
no network encryption settingsWhat this does: It backs up sqlnet.ora and shows any existing encryption or checksum parameters. With none set, the server default is ACCEPTED: it encrypts only if a client asks for it, and almost no client does by default, which matches the clear-text sessions in Step 2.
Step 4: Request Encryption and Integrity on the Server
Start with REQUESTED. The server then encrypts every session with a client that can do it, and still lets older clients connect in clear text, so nothing breaks while you find them. Add these lines to sqlnet.ora on every node of the primary.
Shell |
cat >> $ORACLE_HOME/network/admin/sqlnet.ora <<'EOF'
# Native network encryption and integrity (added for the cross-cloud security review) SQLNET.ENCRYPTION_SERVER = REQUESTED SQLNET.ENCRYPTION_TYPES_SERVER = (AES256) SQLNET.CRYPTO_CHECKSUM_SERVER = REQUESTED SQLNET.CRYPTO_CHECKSUM_TYPES_SERVER = (SHA256) EOF
grep -E '^SQLNET\.(ENCRYPTION|CRYPTO)' $ORACLE_HOME/network/admin/sqlnet.ora |
Expected output |
SQLNET.ENCRYPTION_SERVER = REQUESTED
SQLNET.ENCRYPTION_TYPES_SERVER = (AES256)
SQLNET.CRYPTO_CHECKSUM_SERVER = REQUESTED
SQLNET.CRYPTO_CHECKSUM_TYPES_SERVER = (SHA256)What this does: It asks every client for AES256 encryption and SHA256 integrity, and accepts only those algorithms. No database or listener restart is needed: each new server process reads sqlnet.ora when the connection arrives. On RAC, apply it to the sqlnet.ora of the database home on every node. If the database uses a separate Grid Infrastructure listener, the database home's sqlnet.ora is still the one that counts for the session.
Tip: Some releases also support SQLNET.ALLOW_WEAK_CRYPTO = FALSE, which makes the server refuse deprecated algorithms outright. Check that your release and Release Update support the parameter before adding it, because an unknown parameter is ignored silently.
Step 5: Verify a New Connection
Open a new connection from a client and repeat the query from Step 1. Existing sessions are unchanged; only new ones negotiate.
SQL |
-- New session from the same client host COLUMN network_service_banner FORMAT A86
SELECT network_service_banner FROM v$session_connect_info WHERE sid = SYS_CONTEXT('USERENV', 'SID'); |
Expected output |
NETWORK_SERVICE_BANNER
--------------------------------------------------------------------------------------
TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production
Encryption service for Linux: Version 19.0.0.0.0 - Production
AES256 Encryption service adapter for Linux: Version 19.0.0.0.0 - Production
Crypto-checksumming service for Linux: Version 19.0.0.0.0 - Production
SHA256 Crypto-checksumming service adapter for Linux: Version 19.0.0.0.0 - ProductionWhat to expect: Two new adapter lines naming AES256 and SHA256. The session is now encrypted and integrity-checked end to end. The JDBC thin driver supports native network encryption too; it negotiates with the server's settings without any change to the connect string.
Step 6: Roll the Application Connections and Re-Count
Application pools keep their old connections for hours. Recycle them, one application server at a time, through the normal rolling restart or by having the pool refresh its connections. Then run the query from Step 2 again.
SQL |
SELECT s.machine, s.program, COUNT(*) AS sessions FROM gv$session s WHERE s.type = 'USER' AND NOT EXISTS (SELECT 1 FROM gv$session_connect_info c WHERE c.inst_id = s.inst_id AND c.sid = s.sid AND c.serial# = s.serial# AND c.network_service_banner LIKE '%Encryption service adapter%') AND s.machine <> (SELECT host_name FROM v$instance) GROUP BY s.machine, s.program ORDER BY sessions DESC; |
Expected output |
MACHINE PROGRAM SESSIONS
-------------------- ------------------------------ ----------
report-legacy-01 ReportSrv.exe 4What to expect: Only the clients that cannot or will not encrypt remain. Here one legacy reporting server with an old client library is left. That is the list you must fix before Step 8: upgrade its Oracle client, or set its own sqlnet.ora to request AES256.
Step 7: Cover Data Guard in Both Directions
Redo transport is just another Oracle Net connection: the primary's transport processes are the client and the standby's RFS processes are the server. Because roles change at switchover, put the same settings in sqlnet.ora on the standby too, then check the redo sessions arriving there.
Shell |
# On the standby host sales-az-db1, same lines as Step 4 grep -E '^SQLNET\.(ENCRYPTION|CRYPTO)' $ORACLE_HOME/network/admin/sqlnet.ora |
SQL |
-- On the standby: network services of the sessions coming from the primary host COLUMN network_service_banner FORMAT A86
SELECT c.network_service_banner, COUNT(*) AS sessions FROM v$session s JOIN v$session_connect_info c ON c.sid = s.sid AND c.serial# = s.serial# WHERE s.machine = 'sales-oci-db1' AND c.network_service_banner LIKE '%adapter%' GROUP BY c.network_service_banner; |
Expected output |
NETWORK_SERVICE_BANNER SESSIONS
-------------------------------------------------------------------------------------- ----------
AES256 Encryption service adapter for Linux: Version 19.0.0.0.0 - Production 3
SHA256 Crypto-checksumming service adapter for Linux: Version 19.0.0.0.0 - Production 3
TCP/IP NT Protocol Adapter for Linux: Version 19.0.0.0.0 - Production 3What to expect: The redo transport sessions from the primary use AES256 and SHA256. Existing transport connections keep their old settings until they reconnect; a log switch on the primary (ALTER SYSTEM SWITCH LOGFILE) or a brief deferral and re-enable of the destination makes them reconnect. Watch transport lag in V$DATAGUARD_STATS afterwards: on modern CPUs with AES instructions, the overhead is small, but measure it on your own redo rate.
Step 8: Make Encryption Mandatory
When the count from Step 6 is zero, change REQUESTED to REQUIRED on every node of the primary and the standby. From then on, a client that cannot encrypt is refused instead of silently connecting in clear text.
Shell |
sed -i 's/^SQLNET.ENCRYPTION_SERVER = REQUESTED/SQLNET.ENCRYPTION_SERVER = REQUIRED/; s/^SQLNET.CRYPTO_CHECKSUM_SERVER = REQUESTED/SQLNET.CRYPTO_CHECKSUM_SERVER = REQUIRED/' \ $ORACLE_HOME/network/admin/sqlnet.ora
grep -E '^SQLNET\.(ENCRYPTION|CRYPTO)_.*SERVER =' $ORACLE_HOME/network/admin/sqlnet.ora
# Test from a client configured to reject encryption: the connection must fail sqlplus -L scott@//sales-oci-db1.example.internal:1521/sales_app |
Expected output |
SQLNET.ENCRYPTION_SERVER = REQUIRED
SQLNET.CRYPTO_CHECKSUM_SERVER = REQUIRED
ERROR:
ORA-12660: Encryption or crypto-checksumming parameters incompatibleWhat this does: With REQUIRED on the server, a client whose sqlnet.ora sets SQLNET.ENCRYPTION_CLIENT = REJECTED (or that supports none of the server's algorithms) receives ORA-12660 and cannot connect. That failed test is the evidence the security review wants: clear text is no longer possible, not just unlikely.
Step 9: Know When TLS Is the Better Choice
Native network encryption is quick to deploy, but it is not the answer for every case. Choose TLS (TCPS) instead, or in addition, when:
You need server authentication. TLS with certificates proves to the client that it is talking to the real database, which protects against person-in-the-middle attacks. Native encryption encrypts, but does not authenticate the server.
A standard demands TLS. Some compliance frameworks name TLS specifically.
The service only offers TLS. Autonomous Database, including on Oracle Database@Azure, accepts connections over TLS (with or without mutual TLS wallets), not native network encryption.
Do not configure both on the same connection: when a session uses TCPS, native network encryption is not applied on top of it.
Summary
Private links between clouds keep traffic off the internet but do not encrypt it. Measure first with V$SESSION_CONNECT_INFO: sessions without an "Encryption service adapter" line are clear text. Add SQLNET.ENCRYPTION_SERVER and SQLNET.CRYPTO_CHECKSUM_SERVER set to REQUESTED, with AES256 and SHA256, to sqlnet.ora on every node; new connections pick it up without a restart. Recycle the pools, fix the clients that remain, apply the same settings on the standby so redo is protected in both directions, then switch to REQUIRED and prove it with a client that is refused. Use TLS where you also need the server to be authenticated.
Comments