UNPKG

@push.rocks/smartproxy

Version:

A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.

31 lines (25 loc) 802 B
import * as fs from 'fs'; import * as path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); export interface ICertificates { privateKey: string; publicKey: string; } export function loadDefaultCertificates(): ICertificates { try { const certPath = path.join(__dirname, '..', 'assets', 'certs'); const privateKey = fs.readFileSync(path.join(certPath, 'key.pem'), 'utf8'); const publicKey = fs.readFileSync(path.join(certPath, 'cert.pem'), 'utf8'); if (!privateKey || !publicKey) { throw new Error('Failed to load default certificates'); } return { privateKey, publicKey }; } catch (error) { console.error('Error loading default certificates:', error); throw error; } }