Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

希望添加PostgreSQL SSL Mode连接支持 #183

Open
hicasper opened this issue Sep 30, 2023 · 7 comments
Open

希望添加PostgreSQL SSL Mode连接支持 #183

hicasper opened this issue Sep 30, 2023 · 7 comments
Labels

Comments

@hicasper
Copy link

部分云服务商提供的PostgreSQL数据库只能通过SSL方式连接,在ecto repo url后面加上ssl的参数似乎也没有用。

还有一个小小建议,docker镜像希望能加个tag(比如日期之类的),每次都覆盖latest,有时需要用历史版本就根本找不到。

再顺便问一下,目前PostgreSQL 14还能正常运行吗?

@Hentioe
Copy link
Owner

Hentioe commented Oct 1, 2023

很好的建议。很快会支持 PostgreSQL 的 SSL 连接。关于镜像 tag,我已经加上,从这里可以看到一个基于日期的标签 2023-10-01 的镜像。现在 master 分支的代码一旦构建就会产生最新的日期的镜像以及 latest 镜像。develop 分支始终更新 develop 标签,不会有日期。

回答你的问题:目前使用 PostgreSQL 14 是完全正常的。但后续很有可能会使用一些新版功能,不兼容旧数据库时会特别通知。

@hicasper
Copy link
Author

hicasper commented Oct 1, 2023

感谢采纳,关于docker tag的问题,其实我更建议用20231001这样的方式,在代码中可以更方便比较版本的大小。

@Hentioe
Copy link
Owner

Hentioe commented Oct 8, 2023

我正在开发测试这部分。我不清楚你用的什么云服务商,各家的可能也不同。按照 PostgreSQL 官方的说明,客户端需要有根证书的 crt 文件,你使用的云服务商是否提供?

@hicasper
Copy link
Author

hicasper commented Oct 9, 2023

我正在开发测试这部分。我不清楚你用的什么云服务商,各家的可能也不同。按照 PostgreSQL 官方的说明,客户端需要有根证书的 crt 文件,你使用的云服务商是否提供?

我测试过多家,包括 aiven.io , yugabytedb 等,都会提供ca证书内容,但是ecto在配置的时候应该是可以选择不验证证书,具体应该是在ssl_opts: [ verify: verify_none ]这个部分,个人感觉把最基础的ssl支持添加上就好,证书验证部分以后再做也不迟

@hicasper
Copy link
Author

@Hentioe 来看看支持的进度如何了😁

@Hentioe
Copy link
Owner

Hentioe commented May 28, 2024

现在 Policr Mini 更加复杂了,它不单单依赖 PostgreSQL,还有时序数据库 InfluxDB。它可能不适合部署到你说的这种环境中。如果你用的这类产品也支持同时连接 PostgreSQL 和 InfluxDB,我会考虑实现。

@hicasper
Copy link
Author

hicasper commented Jun 4, 2024

现在 Policr Mini 更加复杂了,它不单单依赖 PostgreSQL,还有时序数据库 InfluxDB。它可能不适合部署到你说的这种环境中。如果你用的这类产品也支持同时连接 PostgreSQL 和 InfluxDB,我会考虑实现。

部分DaaS提供的PostgreSQL服务都是只支持SSL方式连接的,我只是提供一些小建议,目前已经解决。似乎是ecto repo对数据库url支持不完善,只能通过修改 config/releases.exs 中config :policr_mini, PolicrMini.Repo部分,手动修改为

config :policr_mini, PolicrMini.Repo,
  url: database_url,
  ssl: true,
  ssl_opts: [
    verify: :verify_none
  ],
  pool_size: String.to_integer(System.get_env("POLICR_MINI_DATABASE_POOL_SIZE") || "10"),
  migration_timestamps: [type: :utc_datetime]

即可完美支持(这个应该也算是ecto考虑不周到),可以考虑通过增加环境变量的方式添加SSL连接支持

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants