如何使用Oracle钱包 [英] How to use oracle wallet

查看:246
本文介绍了如何使用Oracle钱包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将密码存储在Oracle Wallet文件中,该文件将从代码中检索并使用.

I am trying to store password in an Oracle Wallet file which I will retrieve from the code and use.

我试图创建一个钱包并在其中保存凭据:-

I tried to create a wallet and save a credential there:-

$ mkstore -wrl <wallet_location> -createCredential sid scott tiger

Oracle Secret Store Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:   
Create credential oracle.security.client.connect_string1

创建过程不会出现任何错误,但是当我尝试列出证书时,我什么也没得到.

The creation does not give any error but when I try to list the credential, I don’t get anything.

$ mkstore -wrl -listCredential

Oracle Secret Store Tool : Version 12.1.0.2
Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved

此外,如何使用Java检索此密码?

Also, how to retrieve this password using java?

推荐答案

使用钱包连接Oracle DB需要进行以下更改.

For connecting the Oracle DB using wallet requires the following changes.

  1. 您需要创建一个钱包商店,还需要为钱包选择一个密码,并且在修改钱包时需要使用该密码

  1. you need to create a wallet store, you need to also choose a password for the wallet and you need to use this password while modifying the wallet

  • OracleClientHome /bin/mkstore -wrl 要在哪里存储钱包-创建
  • OracleClientHome/bin/mkstore -wrl Where you want to store your wallet -create

例如 C:\ Oracle_11.2.0 \ product \ client_1 \ bin \ mkstore -wrl C:\ Users \ sample \ app \ wallet

e.g. C:\Oracle_11.2.0\product\client_1\bin\mkstore -wrl C:\Users\sample\app\wallet

您需要在tnsnames.ora( OracleClientHome /network/admin/tnsnames.ora)中添加tns条目,并且我们的钱包连接字符串将使用相同的tns条目名称

you need to add the tns entries in tnsnames.ora (OracleClientHome/network/admin/tnsnames.ora) and same tns entry name will be used us wallet connect string

  • TNS_Entry_Name =(DESCRIPTION =(地址=(PROTOCOL = TCP)(HOST = 主机名))(PORT = 端口号))(CONNECT_DATA =(服务器=专用)(SERVICE_NAME = 服务名称)))
  • TNS_Entry_Name=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Hostname)(PORT=Port_Number))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=Service_Name)))

例如 C:\ Oracle_11.2.0 \ product \ client_1 \ network \ admin \ tnsnames.ora

e.g. C:\Oracle_11.2.0\product\client_1\network\admin\tnsnames.ora

  • SAMPLEDB_RO = {DESCRIPTION = {ADDRESS = {PROTOCOL = TCP} {HOST = HostName )(PORT = PortNumber ))(CONNECT_DATA = {SERVER = dicated)( SERVICE_NAME = samplesrv)))
  • SAMPLEDB_RO=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=HostName)(PORT=PortNumber))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=samplesrv)))

您需要使用凭证为上述tns条目创建钱包条目,还需要提供创建钱包时提供的钱包密码.

you need to create wallet entry for the above tns entry with credentials, you also need to provide the wallet password which you have given while creating the wallet.

  • OracleClientHome /bin/mkstore -wrl 要在哪里存储钱包 -createCredential TNS_Entry_Name/Wallet_Entry_name DB_Username DB_Password
  • OracleClientHome/bin/mkstore -wrl Where you want to store your wallet -createCredential TNS_Entry_Name/Wallet_Entry_name DB_Username DB_Password

例如 C:\ Oracle_11.2.0 \ product \ client_1 \ bin \ mkstore -wrl C:\ Users \ sample \ app \ wallet -createCredential SAMPLEDB_RO示例示例

e.g. C:\Oracle_11.2.0\product\client_1\bin\mkstore -wrl C:\Users\sample\app\wallet -createCredential SAMPLEDB_RO sample sample

您需要添加sqlnet.ora文件以将钱包位置和钱包覆盖标志更新为true

you need to add the sqlnet.ora file to update the wallet location and wallet override flag to true

  • WALLET_LOCATION =(SOURCE =(METHOD = FILE)(METHOD_DATA =(DIRECTORY = 您要存储钱包的位置)))
  • SQLNET.WALLET_OVERRIDE = TRUE
  • WALLET_LOCATION =(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=Where you want to store your wallet)))
  • SQLNET.WALLET_OVERRIDE = TRUE

例如

  • WALLET_LOCATION =(SOURCE =(METHOD = FILE)(METHOD_DATA =(DIRECTORY = C:\ Users \ sample \ app \ wallet)))
  • SQLNET.WALLET_OVERRIDE = TRUE

使用钱夹和oracle客户端测试数据库连接,以确保钱夹配置正确

test the db connection using wallet and oracle client to make sure the wallet configurations are correct

  • OracleClientHome /bin/sqlplus/nolog

  • OracleClientHome/bin/sqlplus /nolog

连接 DB_Username / DB_Password @ TNS_Entry_Name

例如

  • 连接样品/样品@SAMPLEDB_RO
  • 连接/@ SAMPLEDB_RO

您需要准备好Java应用程序以使用钱包,并使用以下JVM参数运行Java程序

you need to make the java application ready to use the wallet and run the java program with the below JVM Parameters

  • 将以下jar添加到应用程序类路径.
  • OracleClientHome /jdbc/lib/ojdbc.jar
  • OracleClientHome /jlib/oraclepki.jar
  • OracleClientHome /jlib/osdt_cert.jar
  • OracleClientHome /jlib/osdt_core.jar

  • Add the following jars to the application classpath.
  • OracleClientHome/jdbc/lib/ojdbc.jar
  • OracleClientHome/jlib/oraclepki.jar
  • OracleClientHome/jlib/osdt_cert.jar
  • OracleClientHome/jlib/osdt_core.jar

例如

C:\ Oracle_11.2.0 \ product \ client_1 \ jlib \ osdt_core.jar

C:\Oracle_11.2.0\product\client_1\jlib\osdt_core.jar

更改应用程序配置瘦URL以使用钱包

Change application configuration thin url to use the wallet

jdbc:oracle:thin:/@ TNS_Entry_Name/Wallet_Entry_name

jdbc:oracle:thin:/@TNS_Entry_Name/Wallet_Entry_name

例如

jdbc:oracle:thin:/@ SAMPLEDB_RO

jdbc:oracle:thin:/@SAMPLEDB_RO

还添加以下属性作为JVM Parameters,这有助于库查找oracle钱包

Also add the following properties as JVM Parameters, this help the library to find the oracle wallet

-Doracle.net.tns_admin = OracleClientHome /network/admin -Doracle.net.wallet_location = 要在哪里存储钱包

-Doracle.net.tns_admin=OracleClientHome/network/admin -Doracle.net.wallet_location=Where you want to store your wallet

例如 -Doracle.net.tns_admin = C:\ Oracle_11.2.0 \ product \ client_1 \ network \ admin -Doracle.net.wallet_location = C:\ Users \ sample \ app \ wallet

e.g. -Doracle.net.tns_admin=C:\Oracle_11.2.0\product\client_1\network\admin -Doracle.net.wallet_location=C:\Users\sample\app\wallet

您已经准备好了!

  • 要列出钱包中的现有凭据,可以使用以下命令,但是您需要提供创建钱包时提供的钱包密码.
  • OracleClientHome /bin/mkstore -wrl 要在哪里存储钱包 -listCredential

  • For listing the existing credentials in the wallet you can use the below command, but you need to provide the wallet password which you have given while creating the wallet.
  • OracleClientHome/bin/mkstore -wrl Where you want to store your wallet -listCredential

例如 C:\ Oracle_11.2.0 \ product \ client_1 \ bin \ mkstore -wrl C:\ Users \ sample \ app \ wallet -listCredential

e.g. C:\Oracle_11.2.0\product\client_1\bin\mkstore -wrl C:\Users\sample\app\wallet -listCredential

这篇关于如何使用Oracle钱包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆