postgresql - 使用基于 SSL/TLS 的证书身份验证与 PostgreSQL 数据库的 Tableau Desktop 连接

标签 postgresql odbc tableau-api

我使用证书身份验证(而不是密码)连接到我的 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 证书(但它确实有一个需要 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,并且可以告诉我哪里做错了,我将非常感激。干杯!

最佳答案

我设法自己解决了这个问题,以防万一有人可能对此有兴趣,我将介绍一下主要功能:

<强>1。创建了 DSN(数据存储名称)

  • 这使测试变得更加容易,而不是不断地在对话框中重新键入详细信息。
  • 我没有手动创建,而是使用了这个:http://www.odbcmanager.net/
  • 在 Mac OS 上我必须以 sudo 运行它来自终端,否则它不会创建任何东西。
  • 我创建了一个用户 DSN,在我的 Mac 上它的详细信息存储在 /Users/<user name>/.odbc.ini
  • 它选择了我之前安装的 PostgreSQL Unicode 驱动程序。在 Mac OS 上,您可能需要执行 brew install brew install psqlodbc和/或 brew install unixodbc
  • 大部分配置都是通过添加键/值对来指定的,例如DBNAME <db name>
  • 设置SSLMODE verify-ca (从 require 更改为特定行为 - 如果提供 SSL 证书,psql 假定 verify-ca/verify-full)
  • 证书路径设置为 key Pqopt , 值 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 连接器略有不同。表格最初没有出现在左侧。但它们是可访问的 - 它们都可以通过单击“包含”单选按钮并使用空白名称搜索来显示。

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

关于postgresql - 使用基于 SSL/TLS 的证书身份验证与 PostgreSQL 数据库的 Tableau Desktop 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57725031/

相关文章:

mysql - MariaDB 创建表 SQL 错误 : 1170

odbc - 是否可以通过 ODBC 驱动程序将 Power BI 连接到 kdb 数据库?

sql - 如何计算同一列中不同类别的日期之间的差异?

python - 带有 pg8000 的 PostgreSQL - 将 SQL 的结果插入到另一个表

PostgreSQL daterange 没有正确使用索引

sql - postgreSQL 根据 ID 匹配从一个表更新到另一个表

c# - 当文件路径/名称有空格时使用 System.Data.Odbc.OdbcConnection 查询 DBF 文件

Java sql ResultSet没有数据

javascript - 如何实现 Tableau 可信身份验证?

javascript - 在 Tableau 中使用 Promise 解析 Json