ulixee / secret-agent

The web scraper that's nearly impossible to block - now called @ulixee/hero
https://secretagent.dev
MIT License
669 stars 44 forks source link

Random CertificateGeneratore error on load when restarting machine. #406

Open blakebyrnes opened 2 years ago

blakebyrnes commented 2 years ago

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'```
blakebyrnes commented 2 years ago

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

blakebyrnes commented 2 years ago

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