SQLPLUS无法从ewallet.p12文件获取凭据

时间:2020-07-30 12:07:21

标签: oracle sqlplus oracle-wallet

遵循https://docs.oracle.com/cd/E78494_01/aip/pdf/1411/html/ig/aip-ig-apx_wallet.htm指南并创建ewallet.p12(还生成cwallet.sso),sqlnet.ora和tnsnames.ora:

PS C:\Users\myname\Oracle> echo $env:ORACLE_HOME
C:\app\oracle\product\19.0.0\client_1
PS C:\Users\myname\Oracle> echo $env:TNS_ADMIN
C:\Users\myname\Oracle\my_admin

然后测试了我的凭据,并且tnsnames.ora成功:

sqlplus user/password@tns_alias

但是,从上方删除用户和密码(希望从ewallet.p12文件中删除它们)错误:

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jul xxxxxxxxx
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied
Enter user-name:

,然后在出现提示时输入用户名和密码,给我tns适配器错误:

Enter user-name: user
Enter password:
ERROR:
ORA-12560: TNS:protocol adapter error

以下是sqlnet.ora的内容:

SSL_CLIENT_AUTHENTICATION=FALSE
SSL_SERVER_DN_MATCH=TRUE

WALLET_LOCATION = 
    (SOURCE = 
    (METHOD=FILE) (METHOD_DATA = (DIRECTORY = C:\Users\myname\Oracle\my_wallet)))

TRACE_LEVEL_CLIENT=16
TRACE_FILE_CLIENT = client.trc
TRACE_DIRECTORY_CLIENT=%USERPROFILE%\ORACLE

和钱夹文件夹的内容:

PS P:\> ls C:\Users\myname\Oracle\my_wallet\


    Directory: C:\Users\myname\Oracle\my_wallet


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----       30/07/2020   7:59 PM           2509 cwallet.sso
-a----       30/07/2020   7:39 PM              0 cwallet.sso.lck
-a----       30/07/2020   7:59 PM           2464 ewallet.p12
-a----       30/07/2020   7:39 PM              0 ewallet.p12.lck

这似乎很简单,但不确定我错过了什么?

1 个答案:

答案 0 :(得分:1)

当您使用WALLET通过密码存储进行身份验证时,最好包含两个其他文件(sqlnet.ora and tnsnames.ora),这些文件与您通常用于使用密码连接的文件不同。

tnsnames.orasqlnet.ora复制到相同的钱包目录,然后执行以下步骤:

3。编辑sqlnet.ora看起来像这样

WALLET_LOCATION =
   (SOURCE =
     (METHOD = FILE)
     (METHOD_DATA =
       (DIRECTORY =  C:\Users\myname\Oracle\my_wallet )
     )
    )

SQLNET.WALLET_OVERRIDE = TRUE
SSL_CLIENT_AUTHENTICATION = FALSE
SSL_VERSION = 0

3。您的新tnsnames.ora必须包含钱包的条目(service_name或sid)

MY_EXAMPLE=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = server  )(PORT = port ))(CONNECT_DATA =(SERVER = DEDICATED)(SID = databasesid)))

4。将TNS_ADMIN设置为新的sqlnet和tnsnames文件的位置

SET TNS_ADMIN=C:\Users\myname\Oracle\my_wallet

5。包含所有文件的目录应类似于(在我的情况下,我使用Linux)

-rw-------. 1 orafil finance    0 Feb  6 16:30 ewallet.p12.lck
-rw-------. 1 orafil finance    0 Feb  6 16:30 cwallet.sso.lck
-rw-rw-r--. 1 orafil finance  235 Feb 18 10:26 sqlnet.ora
-rw-rw-r--. 1 orafil finance  454 May 14 11:35 tnsnames.ora
-rw-------. 1 orafil finance 2872 May 14 14:26 ewallet.p12
-rw-------. 1 orafil finance 2917 May 14 14:26 cwallet.sso

然后连接

sqlplus user/@MY_EXAMPLE