Lines 147-187javascript
147 user: firstCredentialed.user,
148 pass: firstCredentialed.pass
152 * Load and validate TLS certificate/key files from the filesystem.
154 * Reads PEM-formatted certificate and key files from the paths specified in environment configuration.
155 * All file paths are optional and independent.
157 * @param certFilePath - Path to certificate file (PEM format), if present
158 * @param keyFilePath - Path to private key file (PEM format), if present
159 * @param caFilePath - Path to CA certificate file (PEM format), if present
160 * @returns TLS options object with loaded certificates, or undefined if no files are specified
161 * @throws {NATSTLSConfigError} When a file path is configured but the file does not exist,
162 * is unreadable, or contains invalid content
166 * const tls = LoadTlsFiles('/etc/nats/cert.pem', '/etc/nats/key.pem', '/etc/nats/ca.pem');
167 * // => { cert: '-----BEGIN CERTIFICATE-----\n...', key: '-----BEGIN PRIVATE KEY-----\n...', ca: '-----BEGIN CERTIFICATE-----\n...' }
CriticalCritical Secret
Package contains a critical-looking secret pattern.
dist/connection-options.jsView on unpkg · L167 CriticalSecret Pattern
RSA private key in dist/connection-options.js
dist/connection-options.jsView on unpkg · L167 170function LoadTlsFiles(certFilePath, keyFilePath, caFilePath) {
171 // If no files are specified, return undefined
172 if (!certFilePath && !keyFilePath && !caFilePath) {
178 tls.cert = readFileSync(certFilePath, 'utf8');
182 const err = error instanceof Error ? error : new Error(String(error));
183 throw new NATSTLSConfigError(`Failed to load NATS_TLS_CERT_FILE at ${certFilePath}: ${err.message}`, err);
187 tls.key = readFileSync(keyFilePath, 'utf8');