Use castage/pki for PEM-encoded key and certificate values. These casters normalize escaped \n sequences, which makes them convenient for values loaded from environment-like sources without making them part of the env entrypoint.
import { rsaPrivateKey, rsaPublicKey, x509Certificate } from 'castage/pki';
rsaPrivateKey('-----BEGIN RSA PRIVATE KEY-----\\n...\\n-----END RSA PRIVATE KEY-----');
rsaPublicKey('-----BEGIN PUBLIC KEY-----\\n...\\n-----END PUBLIC KEY-----');
x509Certificate('-----BEGIN CERTIFICATE-----\\n...\\n-----END CERTIFICATE-----');rsaPrivateKey: Ensures an RSA private PEM key and normalizes escaped\nsequences.rsaPublicKey: Ensures an RSA public PEM key and normalizes escaped\nsequences.x509Certificate: Ensures an X.509 PEM certificate and normalizes escaped\nsequences.