Pgssl
SSL proxy for PostgreSQL that wraps plain connections into SSL
Install / Use
/learn @glebarez/PgsslREADME
pgSSL
pgSSL is a proxy for PostgreSQL that wraps plain TCP connections (sslmode=disable) into SSL and provides (optional) client certificate to the backend PostgreSQL server. This way it allows SSL encryption and certificate-based authentication for plain-text PostgreSQL clients.
Motivation
PostgreSQL listens to both plain and SSL connections on a single port, therefore it has its own handshake that precedes the usual SSL/TLS handshake.
For this reason it's not possible to wrap plain connections into SSL with usual proxies like nginx, envoy, istio, HAproxy.
Though pgbouncer can be used for such task, the purpose of pgbouncer is to load-balance and pool the connections, so for a simple SSL-wrap it seems to be overkill.
pgSSL wraps connections with regard to PostgreSQL-specific SSL handshake.
How it works
sequenceDiagram
client->>pgSSL: TCP connect (plain)
pgSSL-->>PostgreSQL: SSLRequest
PostgreSQL-->>pgSSL: S(OK)
pgSSL-->>PostgreSQL: SSL Handshake
PostgreSQL-->>pgSSL: SSL Handshake complete
loop
client->>pgSSL: plain query
activate pgSSL
pgSSL-->>PostgreSQL: encrypted query
deactivate pgSSL
PostgreSQL-->>pgSSL: encrypted result
activate pgSSL
pgSSL->>client: plain result
deactivate pgSSL
end
Installation
go install github.com/glebarez/pgssl
Usage examples
pgssl -p postgres-server:5432 -l :15432 -k client.key -c client.crtpgssl -p postgres-server:5432 -l :15432PGSSL_PASSWORD=changeme pgssl -p postgres-server:5432 -l :15432
Related Skills
feishu-drive
339.3k|
things-mac
339.3kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
339.3kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
yu-ai-agent
2.0k编程导航 2025 年 AI 开发实战新项目,基于 Spring Boot 3 + Java 21 + Spring AI 构建 AI 恋爱大师应用和 ReAct 模式自主规划智能体YuManus,覆盖 AI 大模型接入、Spring AI 核心特性、Prompt 工程和优化、RAG 检索增强、向量数据库、Tool Calling 工具调用、MCP 模型上下文协议、AI Agent 开发(Manas Java 实现)、Cursor AI 工具等核心知识。用一套教程将程序员必知必会的 AI 技术一网打尽,帮你成为 AI 时代企业的香饽饽,给你的简历和求职大幅增加竞争力。
