UNPKG

rex-server

Version:

Rex Server is a Node.js-based reverse proxy server available as an npm package. It allows you to handle HTTP and HTTPS traffic, route requests to upstream servers, and manage worker processes efficiently. With its CLI interface, Rex makes it easy to confi

43 lines (42 loc) 1.79 kB
/** * Retrieves the SSL configuration by reading the certificate and key files. * * This function takes an object with paths to the SSL certificate and key files, * reads the files synchronously, and returns an SSL configuration object containing: * - The certificate content * - The private key content * - SSL options to disable SSLv2 and SSLv3 for improved security. * * @param {Object} sslConfig - An object containing the paths to the SSL certificate and private key files. * @param {string} sslConfig.cert - The path to the SSL certificate file. * @param {string} sslConfig.key - The path to the SSL private key file. * * @returns {Object} An object containing: * - `cert` (Buffer): The content of the SSL certificate file. * - `key` (Buffer): The content of the SSL private key file. * - `secureOptions` (number): Security options to disable SSLv2 and SSLv3. * * @throws {Error} If there is an issue reading the certificate or key files. * * @example * const sslConfig = getSSLConfig({ cert: '/path/to/cert.pem', key: '/path/to/key.pem' }); * console.log(sslConfig.cert); // Outputs the SSL certificate content. * console.log(sslConfig.key); // Outputs the SSL private key content. */ export declare function getSSLConfig(sslConfig: { cert: string; key: string; }): { cert: Buffer<ArrayBufferLike>; key: Buffer<ArrayBufferLike>; secureOptions: number; }; /** * Extracts the hostname from an SSL certificate file. * * @param certPath - The file path to the SSL certificate. * @returns The hostname extracted from the certificate. If extraction fails, returns 'localhost'. * * @throws Will log an error and return 'localhost' if an error occurs during extraction. */ export declare function getHostnameFromSSL(certPath: string): string;