As of 2023-01-25 there has been an issue with GitHub CoPilot plugin on Intellij (and other IDEs supporting GitHub CoPilot as well) that if the machine had self-signed certificates (like in an office laptop) then it would throw following error :

Sign in failed. Reason: Request signInInitiate failed with message: self signed certificate in certificate chain, request id: 3, error code: -32603

GitHub CoPilot Issue Screenshot

In this post I am proposing a fix that works fine as of 2023-01-25.

Fix

  1. Export the self-signed certificate in your respective OS. For example, in macOS, it would be present in Keychain Access -> Certificate which you can right-click and export.
  2. Convert the certificate to .pem format. For example, if the certificate is in .cer format then you run this :
    openssl x509 -inform der -in <exported_cert>.cer -out mycert.pem
    
  3. Export NODE_EXTRA_CA_CERTS=<path_to_mycert.pem> variable. For example, if you are using ZSH you add this in ~/.zshrc
    export NODE_EXTRA_CA_CERTS="<path_to_mycert.pem>"
    
  4. Re-start your Intellij and this should now work.