当前位置: 首页 > news >正文

实用指南:Configuration of TCP/IP with SSL and TLS for Database Connections

https://oracle-base.com/articles/misc/configure-tcpip-with-ssl-and-tls-for-database-connections

From 10g Release 2 onward, Native Network Encryption and TCP/IP with SSL/TLS are no longer part of the Advanced Security Option. This article describes the server and client configuration needed to use TCP/IP with SSL and TLS for database connections.

Like the Oracle documentation, this article uses the terms SSL and TLS interchangeably. Connections use SSL or TLS depending on the cipher suites selected. Place the ciphers in the strongest-to-weakest order in the list.

 Network encryption is of prime importance to you if you are considering moving your databases to the cloud.

  • Prerequisites and Assumptions
  • Server Wallet and Certificate
  • Client Wallet and Certificate
  • Exchange Certificates
  • Server Network Configuration
  • Client Network Configuration
  • Test Connection
  • Oracle on Windows

Related articles.

  • Native Network Encryption for Database Connections

Prerequisites and Assumptions

This article assumes the following prerequisites are in place.

  • A functioning database server. In this case we are using Oracle 12c (12.1.0.2) running on Oracle Linux 7 (OL7) and the server name is "ol7-121.localdomain". The setup is the same for other versions of the database and Linux.
  • A client machine with an Oracle Client installed. In this case we are using an Oracle 11.2.0.3 client installed on a Windows 7 PC called "my-computer".
  • There are no local or network firewalls blocking communication with the server on port 2484.
  • The examples in this article use self signed certificates, but you can just as easily use proper certificate authority certificates if you prefer. This is probably not necessary as you will only be using these certificates inside your own organisation, or possibly to communicate between your on-premise and cloud infrastructure.

Server Wallet and Certificate

Create a new auto-login wallet.

$ mkdir -p /u01/app/oracle/wallet$ orapki wallet create -wallet "/u01/app/oracle/wallet" -pwd WalletPasswd123 -auto_login_local
Oracle PKI Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.$

Create a self-signed certificate and load it into the wallet.

$ orapki wallet add -wallet "/u01/app/oracle/wallet" -pwd WalletPasswd123 \-dn "CN=`hostname`" -keysize 1024 -self_signed -validity 3650
Oracle PKI Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.$

Check the contents of the wallet. Notice the self-signed certificate is both a user and trusted certificate.

$ orapki wallet display -wallet "/u01/app/oracle/wallet" -pwd WalletPasswd123
Oracle PKI Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.Requested Certificates:
User Certificates:
Subject:        CN=ol7-121.localdomain
Trusted Certificates:
Subject:        CN=ol7-121.localdomain
$

Export the certificate, so we can load it into the client wallet later.

$ orapki wallet export -wallet "/u01/app/oracle/wallet" -pwd WalletPasswd123 \-dn "CN=`hostname`" -cert /tmp/`hostname`-certificate.crt
Oracle PKI Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.$

Check the certificate has been exported as expected.

$ cat /tmp/`hostname`-certificate.crt
-----BEGIN CERTIFICATE-----
MIIBqzCCARQCAQAwDQYJKoZIhvcNAQEEBQAwHjEcMBoGA1UEAxMTb2w3LTEyMS5sb2NhbGRvbWFp
bjAeFw0xNTA2MjYxNDQyMDJaFw0yNTA2MjMxNDQyMDJaMB4xHDAaBgNVBAMTE29sNy0xMjEubG9j
YWxkb21haW4wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAJIrU1fGWAwMxRobFsS0UZBD1jFU
wAvnH9blsynhrQrZSkwyMBWGPRFq5tufRpaifoNVVHSrjJm/nti62A6RXECAKsug9rHL8T11FOgP
3R/+Itw2jLzwpdk7MbHMxpNHz6Y2IPCmBsJ5+625dRxugVKhLsIitAW5cUpT28bkrMl9AgMBAAEw
DQYJKoZIhvcNAQEEBQADgYEABqQaP056WcPNgzSAOhJgTU/6D8uAFGCgUN57HoraXxgAN3HgmeGq
hQfpb8tP+xeTF3ecqvWqJQHGdAJbuhRwpNR1rRovvlOxiv4gl0AplRzRuiygXfi6gst7KNmAdoxr
TOcUQsqf/Ei9TaFl/N8E+88T2fK67JHgFa4QDs/XZWM=
-----END CERTIFICATE-----
$

Client Wallet and Certificate

Create a new auto-login wallet.

c:\>mkdir -p c:\app\oracle\walletc:\>orapki wallet create -wallet "c:\app\oracle\wallet" -pwd WalletPasswd123 -auto_login_local
Oracle PKI Tool : Version 11.2.0.3.0 - Production
Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.c:\>

Create a self-signed certificate and load it into the wallet.

c:\>orapki wallet add -wallet "c:\app\oracle\wallet" -pwd WalletPasswd123 -dn "CN=%computername%" -keysize 1024 -self_signed -validity 3650
Oracle PKI Tool : Version 11.2.0.3.0 - Production
Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.c:\>

Check the contents of the wallet. Notice the self-signed certificate is both a user and trusted certificate.

c:\>orapki wallet display -wallet "c:\app\oracle\wallet" -pwd WalletPasswd123
Oracle PKI Tool : Version 11.2.0.3.0 - Production
Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.Requested Certificates:
User Certificates:
Subject:        CN=my-computer
Trusted Certificates:
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security\, Inc.,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions\, Inc.,O=GTE Corporation,C=US
Subject:        CN=my-computer
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign\, Inc.,C=USc:\>

Export the certificate so we can load it into the server later.

c:\>orapki wallet export -wallet "c:\app\oracle\wallet" -pwd WalletPasswd123 -dn "CN=%computername%" -cert c:\%computername%-certificate.crt
Oracle PKI Tool : Version 11.2.0.3.0 - Production
Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.c:\>

Check the certificate.

c:\>more c:\%computername%-certificate.crt
-----BEGIN CERTIFICATE-----
MIIBmzCCAQQCAQAwDQYJKoZIhvcNAQEEBQAwFjEUMBIGA1UEAxMLSVRTLUYxTUxDNUowHhcNMTUw
NjI2MDkzMzE2WhcNMjUwNjIzMDkzMzE2WjAWMRQwEgYDVQQDEwtJVFMtRjFNTEM1SjCBnzANBgkq
hkiG9w0BAQEFAAOBjQAwgYkCgYEAk/oX7ulDhW+DKXdD+qYC9DN7DoTsmeGZaW7EwYr48sw2qQWK
HP3pFb8/eVLHuqd2tX8RCniI6Dy5iMe7aM+BOvtGDT2bkCENO7xflww+L/Jp1JeF4OCawE36/Coy
sWAu4yom7n109ioT2rQsN62ERj8wPa53r8KAB12UnidBzRECAwEAATANBgkqhkiG9w0BAQQFAAOB
gQB7hbEUXM3ur2H2osuaX24mxmw83yxLnvx9BDi10kbTdH02St/EfCNlCWc69L5iAeJVESvaVgJQ
u1AZEeD3jPYMFWTnGfX4txo7+GJWwpxCJXqYYrmYQL2h1W6UtTVsJgQ08wo2bTHTjII6HB6wt8CK
OU46CFGLL+7B7Xrpnk1UwA==
-----END CERTIFICATE-----c:\>

Exchange Certificates

Each side of the connection needs to trust the other, so we must load the certificate from the server as a trusted certificate into the client wallet and vice versa.

Load the server certificate into the client wallet.

c:\>orapki wallet add -wallet "c:\app\oracle\wallet" -pwd WalletPasswd123 -trusted_cert -cert c:\ol7-121.localdomain-certificate.crt
Oracle PKI Tool : Version 11.2.0.3.0 - Production
Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.c:\>

Check the contents of the client wallet. Notice the server certificate is now included in the list of trusted certificates.

c:\>orapki wallet display -wallet "c:\app\oracle\wallet" -pwd WalletPasswd123 
Oracle PKI Tool : Version 11.2.0.3.0 - Production
Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.Requested Certificates:
User Certificates:
Subject:        CN=my-computer
Trusted Certificates:
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security\, Inc.,C=US
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        CN=my-computer
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign\, Inc.,C=US
Subject:        CN=ol7-121.localdomain
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions\, Inc.,O=GTE Corporation,C=USc:\>

Load the client certificate into the server wallet.

$ orapki wallet add -wallet "/u01/app/oracle/wallet" -pwd WalletPasswd123 \-trusted_cert -cert /tmp/my-computer-certificate.crt
Oracle PKI Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.$

Check the contents of the server wallet. Notice the client certificate is now included in the list of trusted certificates.

$ orapki wallet display -wallet "/u01/app/oracle/wallet" -pwd WalletPasswd123
Oracle PKI Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.Requested Certificates:
User Certificates:
Subject:        CN=ol7-121.localdomain
Trusted Certificates:
Subject:        CN=my-computer
Subject:        CN=ol7-121.localdomain
$

Server Network Configuration

On the server, add the following entries into the "$ORACLE_HOME/network/admin/sqlnet.ora" file.

WALLET_LOCATION =(SOURCE =(METHOD = FILE)(METHOD_DATA =(DIRECTORY = /u01/app/oracle/wallet)))SQLNET.AUTHENTICATION_SERVICES = (TCPS,NTS,BEQ)
SSL_CLIENT_AUTHENTICATION = FALSE
SSL_CIPHER_SUITES = (SSL_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA)

 You probably need to think about what cipher suites you want to support. You may wish to avoid those that support SSLv3 in favour of those that support TLS only. Your decision my vary depending on the Oracle database and client versions.

Configure the listener to accept SSL/TLS encrypted connections. Edit the "$ORACLE_HOME/network/admin/listener.ora" file, adding the wallet information, as well as the TCPS entry.

SSL_CLIENT_AUTHENTICATION = FALSEWALLET_LOCATION =(SOURCE =(METHOD = FILE)(METHOD_DATA =(DIRECTORY = /u01/app/oracle/wallet)))LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = ol7-121.localdomain)(PORT = 1521))(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))(ADDRESS = (PROTOCOL = TCPS)(HOST = ol7-121.localdomain)(PORT = 2484))))ADR_BASE_LISTENER = /u01/app/oracle

Restart the listener.

$ lsnrctl stop
$ lsnrctl start

The server is now configured.

Client Network Configuration

Edit the "$ORACLE_HOME/network/admin/sqlnet.ora" file, adding the following lines.

WALLET_LOCATION =(SOURCE =(METHOD = FILE)(METHOD_DATA =(DIRECTORY = c:\app\oracle\wallet)))SQLNET.AUTHENTICATION_SERVICES = (TCPS,NTS)
SSL_CLIENT_AUTHENTICATION = FALSE
SSL_CIPHER_SUITES = (SSL_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA)

 Make sure the client cipher suites match the server configuration.

Edit the "$ORACLE_HOME/network/admin/tnsnames.ora" file, making sure the port corresponds to that configured for SSL on the server and the protocol is TCPS.

pdb1_ssl=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=ol7-121.localdomain)(PORT=2484))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=pdb1)))

The client is now configured.

Test Connection

You should now be able to make a connection to the server using the SSL/TLS enabled TNS entry.

c:\>sqlplus test/test@pdb1_sslSQL*Plus: Release 11.2.0.3.0 Production on Fri Jun 26 16:23:28 2015Copyright (c) 1982, 2011, Oracle.  All rights reserved.Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing optionsSQL>

Oracle on Windows

If you install Oracle software under a new local user, you will need to manually make sure that user has permissions on any wallet created. Thanks to Martin Emptage for pointing this out.

For more information see:

Hope this helps. Regards Tim...

http://www.zskr.cn/news/73638.html

相关文章:

  • 20232420 2025-2026-1 《网络与系统攻防技术》实验八实验报告
  • BZOJ1278 向量 vector
  • 2025年度安全狗狗驱虫药品牌排行榜:专业评测助力科学养宠
  • Ubuntu 22.04 与 24.04 常用操作命令
  • 全国中医师承选哪个机构靠谱?——理性对比后选择了阿虎医考师承
  • 深入解析:探索JavaScript前端开发:开启交互之门的神奇钥匙(二)
  • Node-RED:5分钟快速上手:安装与环境安装
  • 个人电脑本地私有知识库推荐:访答软件全解析
  • 缓存击穿,缓存穿透,缓存雪崩的原因和解决方案(或者说使用缓存的过程中有没有遇到什么问题,怎么应对的)
  • 写给自己看,自己写自己
  • 2025年现浇楼板施工验收标准排行,你家合格吗?混凝土现浇/钢筋混凝土现浇/现浇楼梯/现浇楼板现浇楼板多少钱一平推荐榜单
  • GoldenDB数据库工程师培训(中兴GoldenDB金融级/运营商级分布式数据库) 原创
  • 2025年防雨棚厂家供应排行榜,热门联系电话汇总,控制台定做/龙门架监控杆/指挥中心控制台/防雨套/防雨棚生产厂家推荐榜
  • XXE盲注 感受创造之美
  • Rustup 暂时切换国内源并更新
  • 【完整源码+数据集】蓝莓数据集,yolo11蓝莓成熟度检测数据集 3023 张,蓝莓成熟度资料集,目标检测蓝莓识别算法系统实战教程
  • 2025年货架批发厂家口碑推荐TOP5,贯通货架/托盘货架/组合式货架/牛脚式货架/穿梭式货架/仓库存储货架源头厂家推荐
  • 深度学习:python人脸表情识别系统 情绪识别系统 深度学习 神经网络CNN算法 ✅ - 指南
  • 5
  • 2025年必看:花灯厂家排行,彩车花灯工艺谁更优?华景花灯/夜景布置灯/商场美陈花灯/古镇花灯/演绎花灯生产商有哪些
  • 102302104刘璇-数据采集与融合技术实践作业4
  • 高精度计算
  • 看马蜂猜人 2.0
  • Meta 挖角苹果设计师,重塑 AI 硬件交互;健康追踪应用 Healthify 升级 AI 助手:实时语音与摄像头交互丨日报
  • LocalAI:一个免费开源的AI替代实用的方案,让创意更自由!
  • kanass零基础学习,项目负责人如何启用kanass驾驭项目
  • PbootCMS网站转移后无法打开报错提示“No input file specifed”
  • Object类
  • HTML--------------动态列表
  • PbootCMS提示错误信息“未检测到您服务器环境的sqlite3数据库扩展...”