ulixee/secret-agent

Random CertificateGeneratore error on load when restarting machine.

blakebyrnes opened this issue · 2 comments

Secret Agent occasionally throws a private key error when booting up. Something in the CertificateGenerator must be unable to load the key files (or there is a timing bug). As reported on discord:

  errorKind: 'ClientToProxy.GenerateCertError',
  errorCodes: [ undefined, 'ERR_OSSL_X509_KEY_VALUES_MISMATCH' ],
  hostname: 'website:443',
  context: {},
  sessionId: 'sessionId',
  sessionName: 'default-session'
} Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
    at setKey (node:internal/tls/secure-context:88:11)
    at configSecureContext (node:internal/tls/secure-context:168:7)
    at Object.createSecureContext (node:_tls_common:116:3)
    at Http2SecureServer.Server.addContext (node:_tls_wrap:1452:31)
    at MitmProxy.addSecureContext (/Users/removed/node_modules/mitm/lib/MitmProxy.ts:440:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  library: 'x509 certificate routines',
  function: 'X509_check_private_key',
  reason: 'key values mismatch',
  code: 'ERR_OSSL_X509_KEY_VALUES_MISMATCH'```

NOTE: if you run into this, you can delete the network.db in your sessions dir to keep moving

I can't figure out exactly what's triggering this, but I think we should just store the "private key" that generated each certificate in the networks.db folder. I have this code in Hero. Just need to port