tls#createSecureContext TypeScript Examples

The following examples show how to use tls#createSecureContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: impl.ts    From kassette with MIT License 6 votes vote down vote up
private async _getSecureContext(host: string) {
    let res = this._contexts.get(host);
    if (!res) {
      res = (async () => {
        const certificate = await createCertificate([host], {
          issuer: this._caObject,
          ca: false,
          keySize: this._config.tlsKeySize,
        });
        return createSecureContext({
          cert: `${certificate.cert}\n${this._caPem}`,
          key: certificate.key,
        });
      })();
      this._contexts.set(host, res);
    }
    return res;
  }