UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.4 kB
import{i as readFileDescriptorBounded}from"./boundary-file-read-LFsZ_JrU.mjs";import{a as resolveUserPath}from"./home-dir-C2A7IM0a.mjs";import{t as CONFIG_DIR}from"./utils-CfSlIBx_.mjs";import{n as ok,t as err}from"./result-CkiK_t2O.mjs";import{r as normalizeTlsFingerprint}from"./client-address-utils-C1XJsd6v.mjs";import"./resolve-system-bin-CnoUykR_.mjs";import"./exec-DIN7WN3p.mjs";import path from"node:path";import{X509Certificate}from"node:crypto";import fsPromises from"node:fs/promises";import"@openclaw/fs-safe/durability"; //!src/infra/tls/gateway.ts const MAX_TLS_LEAF_FILE_BYTES=65536;async function readTlsLeafFile(e){const t=await fsPromises.open(e,`r`);try{return(await readFileDescriptorBounded(t.fd,MAX_TLS_LEAF_FILE_BYTES)).toString(`utf8`)}finally{await t.close()}}function resolveGatewayTlsCertPath(e){return resolveUserPath(typeof e===`string`&&e.trim()?e:path.join(CONFIG_DIR,`gateway`,`tls`,`gateway-cert.pem`))}async function inspectGatewayTlsCertificate(e){if(e?.enabled!==true)return err(`gateway tls is disabled`);try{const t=await readTlsLeafFile(resolveGatewayTlsCertPath(e.certPath));const n=normalizeTlsFingerprint(new X509Certificate(t).fingerprint256);return n?ok({cert:t,fingerprintSha256:n}):err(`gateway tls: unable to compute certificate fingerprint`)}catch(e){return err(`gateway tls: failed to load cert (${String(e)})`)}}export{inspectGatewayTlsCertificate};