Skip to content

sslutils

A Postgres extension for managing SSL certificates through SQL

Overview

PackageVersionCategoryLicenseLanguage
sslutils1.4.1SECPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
7410sslutilsNoYesNoYesNoNo-

PGDG packages remain absent for PG18 on EL8 x86_64.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY1.4.11817161514sslutils-
RPMPIGSTY1.4.11817161514sslutils_$v-
DEBPIGSTY1.4.11817161514postgresql-$v-sslutils-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
d13.x86_64
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
d13.aarch64
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
u22.x86_64
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
u22.aarch64
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
u24.x86_64
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
u24.aarch64
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
u26.x86_64
u26.aarch64
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4
PIGSTY 1.4

Build

You can build the RPM / DEB packages for sslutils using pig build:

pig build pkg sslutils         # build RPM / DEB packages

Install

You can install sslutils directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

Install
pig install sslutils;          # Install for current active PG version
pig
pig ext install -y sslutils -v 18  # PG 18
pig ext install -y sslutils -v 17  # PG 17
pig ext install -y sslutils -v 16  # PG 16
pig ext install -y sslutils -v 15  # PG 15
pig ext install -y sslutils -v 14  # PG 14
dnf
dnf install -y sslutils_18       # PG 18
dnf install -y sslutils_17       # PG 17
dnf install -y sslutils_16       # PG 16
dnf install -y sslutils_15       # PG 15
dnf install -y sslutils_14       # PG 14
apt
apt install -y postgresql-18-sslutils   # PG 18
apt install -y postgresql-17-sslutils   # PG 17
apt install -y postgresql-16-sslutils   # PG 16
apt install -y postgresql-15-sslutils   # PG 15
apt install -y postgresql-14-sslutils   # PG 14

Create Extension:

CREATE EXTENSION sslutils;

Usage

Sources:

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

CREATE EXTENSION sslutils;
SELECT sslutils_version();
SELECT openssl_get_crt_expiry_date('server.crt');

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

FunctionPurpose
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

Certificate-inspection functions require membership in pg_read_server_files on PostgreSQL 11 and later; revocation checks both that role and pg_write_server_files. These roles provide broad server-file access, so grant them only to trusted administrators and restrict function execution as needed.

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.

File-Access Changes in 1.4.1

Certificate inspection and CA signing paths are checked against the server data directory; place the input files there and use server-relative paths where suitable. Revocation requires sslutils.revoke_certificate_crl_paths, a comma-separated allowlist of CRL output path prefixes configured in postgresql.conf and activated by reload. The revocation check compares lexical string prefixes without resolving canonical directory containment; configure narrow prefixes and protect the output location.

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.

Was this page helpful?