3

我使用证书身份验证(而不是密码)连接到我的 PostgreSQL 数据库(在 AWS EC2 实例上运行)。我将用来连接到我的一个数据库的 psql 命令的一个示例是:

psql "host=<AWS EC2 instance> user=<db user> sslcert=<path to .crt> sslkey=<path to .key> sslrootcert=<path to .crt> sslmode=require dbname=<db name>"

我希望能够将 Tableau Desktop 连接到我的一个数据库。标准 PostgreSQL 连接器不允许我指定要使用的 SSL 证书(但它确实有一个 Require SSL 复选框——我认为它是用于加密而不是身份验证)。

所以我尝试使用 ODBC 连接器。我做了以下条目:

Connect Using
Driver: PostgreSQL Unicode

Connection Attributes
Server: <AWS EC2 instance>
Port: 5432
Database: <db name>
Username: <db user>
String Extras: sslcert=<path to .crt>; sslkey=<path to .key>; sslrootcert=<path to .crt>; sslmode=require

经过反复试验,我认为 String Extras 需要分号作为分隔符,但我仍然无法连接。我收到错误消息:

An error occurred while communicating with Other Databases (ODBC).

Unable to connect to the server. Check that the server is running and that you have access privileges to the requested database.
FATAL:  connection requires a valid client certificate

Generic ODBC requires additional configuration. The driver and DSN (data source name) must be installed and configured to match the connection.
Unable to connect to the server "<AWS EC2 instance>" using the driver "PostgreSQL Unicode". Check that the server is running and that you have access privileges to the requested database.

如果有人使用证书身份验证将 Tableau Desktop 连接到 PostgreSQL,并能告诉我我做错了什么,我将非常感激。干杯!

4

1 回答 1

4

我自己设法解决了这个问题,以防万一有人可能有点兴趣,我将介绍一下突出的特点:

1.创建了DSN(Data Store Name)

  • 这使得测试变得更加容易,而不是不断地在对话框中重新输入细节。
  • 我没有手动创建,而是使用了这个:http ://www.odbcmanager.net/
  • 在 Mac OS 上,我必须sudo从终端运行它,否则它不会创建任何东西。
  • 我创建了一个用户 DSN,它在我的 Mac 上存储了详细信息/Users/<user name>/.odbc.ini
  • 它选择了我之前安装的 PostgreSQL Unicode 驱动程序。在 Mac OS 上,您可能需要执行 brew installbrew install psqlodbc和/或brew install unixodbc
  • 大多数配置是通过添加键/值对来指定的,例如DBNAME <db name>
  • 设置SSLMODE verify-ca(从更改require为特定行为 - 如果提供 SSL 证书,psql 假定 verify-ca/verify-full)
  • 证书路径使用 key Pqopt、 value设置sslcert=<path to .crt> sslkey=<path to .key> sslrootcert=<path to .crt>。必须是小写字母,并且条目之间只有空格!

这是它添加到我用户的 odbc.ini 文件中的内容:

[<DSN name>]
Driver      = <path to driver, this was mine /usr/local/lib/psqlodbcw.so>
Description = <description>
SSLMODE     = verify-ca
HOST        = <host>
DBNAME      = <database>
PORT        = 5432
UID         = <db user>
Pqopt       = sslcert=<path to .crt> sslkey=<path to .key> sslrootcert=<path to .crt>

2. Tableau 桌面连接

  • 选择其他数据库 (ODBC) 连接器。
  • 选择您之前创建的 DSN(它应该会自动获取),它将自动填充主机、端口、数据库和用户字段,然后单击登录。
  • 登录后的行为与专用 PostgreSQL 连接器略有不同。表格最初没有出现在左侧。但它们是可访问的——它们都可以通过单击“包含”单选按钮并使用空白名称进行搜索来显示。

希望这可以帮助。如果您有任何问题,请告诉我。

于 2019-09-02T13:55:24.677 回答