sslutils
sslutils : A Postgres extension for managing SSL certificates through SQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 7410 | sslutils | sslutils | 1.4.2 |
SEC | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| See Also | sslinfo pg_oidc_validator oidc_validator pguecc pg_session_jwt pgjwt pgsodium login_hook libx509pq |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| el8.aarch64 | N/A | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| el9.x86_64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| el9.aarch64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| el10.x86_64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| el10.aarch64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| d12.x86_64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| d12.aarch64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| d13.x86_64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| d13.aarch64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| u22.x86_64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| u22.aarch64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| u24.x86_64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| u24.aarch64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| u26.x86_64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
| u26.aarch64 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 | PIGSTY 1.4.2 |
Source
github.com/EnterpriseDB/sslutils
sslutils-1.4.2.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
- 1.4.2 README
- 1.4.2 SQL API
- 1.4.2 control file
- File-access checks
- 1.4.1 to 1.4.2 upgrade
- PEM agent grants
sslutils provides SSL certificate-generation and revocation helpers for Postgres Enterprise Manager and other controlled administration workflows. Some functions read or modify files on the database server.
Install and Inspect
A superuser must install this non-relocatable extension. No preload or PostgreSQL restart is required to call the functions; deploying generated certificates is a separate server configuration operation.
Important Functions
| Function | Purpose |
|---|---|
openssl_rsa_generate_key(bits) |
Return an RSA private key as text |
openssl_rsa_key_to_csr(key, cn, country, state, location, unit, email) |
Return a CSR |
openssl_csr_to_crt(csr, ca_cert_path, private_key_path, days) |
Sign a CSR using server-side certificate and key files |
openssl_rsa_generate_crl(ca_cert_path, ca_key_path, days) |
Return a certificate revocation list |
openssl_is_crt_expire_on(cert_path, at_time) |
Check certificate expiry; returns 1, -1 or 0 |
openssl_get_crt_expiry_date(cert_path) |
Return the expiry timestamp |
openssl_revoke_certificate(cert_pem, crl_path, days) |
Revoke a certificate and regenerate the CRL |
For self-signed generation, the certificate-path argument to the signing function is NULL and the key path selects the signing key. The optional validity defaults to 3650 days. File paths refer to the PostgreSQL server, not the SQL client’s machine.
Protect Keys and Server Files
In 1.4.2, all seven openssl_* functions use SECURITY DEFINER with a fixed search_path of pg_catalog, pg_temp. Their owner, sslutils_owner, is a cluster-wide INHERIT, NOLOGIN role. It holds pg_read_server_files and pg_write_server_files on PostgreSQL 11 and later, but must have no members, administrative attributes or other role memberships. Installation rejects an unsafe existing owner role.
PUBLIC has no execution privilege. Installation or upgrade grants EXECUTE to pem_agent if that role already exists; existing explicit function grants remain. For an agent created later, a superuser runs the installed sslutils-pemagent.sql in the extension’s schema. An agent using a non-public schema also needs USAGE on that schema, without CREATE. Callers need the relevant function privileges, not direct server-file role membership; never grant them membership in sslutils_owner.
Grant access only to callers trusted to inspect certificates and use CA keys within the permitted paths. Confinement to the data directory does not separate agents or CAs from each other.
Private keys returned as SQL text can enter query results, logs, shell history or application traces. Protect their handling and storage. This extension does not provide SSL session-inspection getters or automatically configure PostgreSQL’s TLS settings.
Upgrade and Existing Grants
Upgrade an existing installation as a superuser:
After migrating callers, remove obsolete broad file-role grants from agents:
Review direct and inherited grants to individual logins too, including pg_execute_server_program and superuser privileges. An extension upgrade within one database does not revoke these cluster-wide grants automatically. The shared sslutils_owner role also survives extension removal; remove it only after uninstalling from all databases and revoking its file-role memberships.
File-Access Boundaries
Certificate inspection and CA signing paths must resolve within the server data directory. Revocation additionally requires sslutils.revoke_certificate_crl_paths, a comma-separated allowlist of CRL output directories configured by a superuser in postgresql.conf and activated by reload. In 1.4.2, checks resolve paths and enforce directory boundaries; a new output file is checked through its existing parent directory, and an existing output file is checked too.
Use dedicated CRL output directories under administrator control. Do not allow the whole data directory or directories containing configuration files: an authorized caller chooses the output filename within an allowed directory. Keep certificate and private-key paths under administrator control as well.
The revocation implementation accepts PEM certificate text as its first argument, despite older README and SQL comments describing a certificate path. It reads the server-side CA files ca_certificate.crt and ca_key.key, and creates or appends to revoke_cert.db. Prepare the CA files before using it. Do not infer that a broad server-file role bypasses these extension-specific checks.