简体   繁体   English

使用带有 SSL 的 ibm_db 连接到 DB2 时出错

[英]Error when connecting to DB2 with ibm_db with SSL

I am trying to connect to DB2 using python module ibm_db with SSL and I get the following error我正在尝试使用带有 SSL 的 python 模块 ibm_db 连接到 DB2,但出现以下错误

 conn = ibm_db.connect("DATABASE=myDB;HOSTNAME=xx.xx.xxx.xxx;PORT=nnn;PROTOCOL=TCPIP;SECURITY=SSL;SSLServerCertificate=./myFile.arm;UID=<username>;PWD=<password>;","","")
stmt = ibm_db.exec_immediate(conn, "delete from myschema.mytable")

I get the following exception我收到以下异常

   Exception: [IBM][CLI Driver] SQL30081N  A communication error has been detected. Communication protocol being used: "SSL".  Communication API being used: "SOCKETS".  Location where the error was detected: "".  Communication function detecting the error: "sqlccSSLSocketSetup".  Protocol specific error code(s): "414", "*", "*".  SQLSTATE=08001 SQLCODE=-30081

I have spent several hours trying to debug.我花了几个小时试图调试。 Can't make any progress here不能在这里取得任何进展

Any help will be appreciated.任何帮助将不胜感激。

Tinniam,提尼亚姆,

How is your gskit keystore (ie .kdb) and stash file (ie .sth file - file storing encrypted password for the keystore) created?您的 gskit 密钥库(即 .kdb)和存储文件(即 .sth 文件 - 存储密钥库加密密码的文件)是如何创建的? Was it creating locally with the same version on the client machine or was it created by someone on other machine that has a different version of gskit?它是在客户端计算机上使用相同版本在本地创建,还是由具有不同版本 gskit 的其他计算机上的某个人创建?

There is a known gskit incompatibility issue ( http://www-01.ibm.com/support/docview.wss?uid=swg22014693 ).存在一个已知的 gskit 不兼容问题 ( http://www-01.ibm.com/support/docview.wss?uid=swg22014693 )。 A stash file generated with version GSKit 8.0.50.69 and newer versions cannot be read by lower version and it will return exactly gskit 414 error.使用版本 GSKit 8.0.50.69 和更新版本生成的存储文件无法被较低版本读取,它将准确返回 gskit 414 错误。

Check the gskit on where your keystore and stash file are created and the version that the client is using.检查您的密钥库和存储文件的创建位置以及客户端使用的版本的 gskit。 There is a gsk8ver_64 tool in sqllib/gskit/bin to tell you the version.在 sqllib/gskit/bin 中有一个 gsk8ver_64 工具告诉你版本。

If indeed, you have hit the incompatibility issue, you need to either upgrade your client to use the version of Db2 that has gskit on the newer boundary release OR: find an older version of Db2 server such as 10.5 fp9 and generate a new keystore and stash file with the lower version of gskit.如果确实遇到了不兼容问题,则需要升级客户端以使用在较新边界版本上具有 gskit 的 Db2 版本,或者:找到较旧版本的 Db2 服务器(例如 10.5 fp9)并生成新的密钥库和使用较低版本的 gskit 存储文件。

NOTE: newer version of gskit can read stash created by lower version.注意:较新版本的 gskit 可以读取由较低版本创建的存储。 But stash file created by 8.0.50.69 and newer versions is not readable by gskit version that is lower than 8.0.50.69 release.但是低于 8.0.50.69 版本的 gskit 版本无法读取由 8.0.50.69 和更新版本创建的存储文件。

Hope this help solve your issue.希望这有助于解决您的问题。

Kevin See凯文·西

Db2 Hybrid Cloud Security Team Db2 混合云安全团队

I had the same issue today while opening an SSL connection from a Db2 Client to a Db2 server.我今天在打开从 Db2 客户端到 Db2 服务器的 SSL 连接时遇到了同样的问题。 SQL30081N with error code 414. Db2 docs pointed to this https://www.ibm.com/support/knowledgecenter/en/SSVJJU_6.3.0/com.ibm.IBMDS.doc/progref506.htm and the hint was 414 – Incorrectly formatted certificate received from partner. SQL30081N 错误代码为 414。Db2 文档指向此https://www.ibm.com/support/knowledgecenter/en/SSVJJU_6.3.0/com.ibm.IBMDS.doc/progref506.htm并且提示为 414 – 格式不正确从合作伙伴处收到的证书。

We figured out sometime later, we have just imported the public key of our server into the client trust keyring.后来我们发现,我们刚刚将服务器的公钥导入到客户端信任密钥环中。 Correct is to import only the public keys of the root server and the intermediate server into the client trust store.正确的是只将根服务器和中间服务器的公钥导入客户端信任库。 You do not need to import the server public key (signed by the intermediate server) into the client trust store.您不需要将服务器公钥(由中间服务器签名)导入客户端信任库。

I hope, the original poster has already found a solution and I just wanted to leave here my solution for the next person with the same issue.我希望,原来的海报已经找到了解决方案,我只是想把我的解决方案留在这里给下一个有同样问题的人。

I would recommend to investigate how the SSL / TLS communication is configured, how the certificate is managed.我建议调查 SSL / TLS 通信的配置方式以及证书的管理方式。

The SSL-specific error is documented as GSKit issue related to certificates .特定于 SSL 的错误记录为与证书相关的 GSKit 问题 You probably have checked the recommendations for the error SQL30081N .您可能已经检查了错误 SQL30081N建议 The error SQL30081N even has protocol-specific details for the error codes. 错误 SQL30081N 甚至包含错误代码的特定协议的详细信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM