I don't understand why Android Studio behaving weird, sending this Untrusted Server Certificate request again and again. Please suggest how to avoid this?

Pop up for accept or reject

5

Best Answer


I was facing this and came across a solution on JetBrain's community page.

To get rid of that, we need to make Idea Accept non-trusted certificates automatically.

Preferences -> Tools -> Server Certificates -> Check on "Accept non-trusted certificates automatically"

[EDIT]: This is not the best solution in terms of security.

Preference page

You see this dialog b/c the proxy server in your network substitutes signed remote certificate certificate with it's own (non-trusted) certificate, hence it can not pass the JDK validation and IDE warns about it.

To fix this import this certificate to the JDK's which IDE uses to run trust store:

keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -alias Root -import -file certFile.cer

See Import the Certificate as a Trusted Certificate for more information.

Happens when connected to a proxy server on your network and your network has an internal certificate authority. The remote certificate is replaced with another untrusted certificate that fails Java validation.

You can either import this cert to your local JDK installation or enable Auto accepting non-trusted certs.

To Enable Auto import,

Mac:Go to IntelliJ IDEA > Preferences > Tools > Server Certificates[x] Check on Accept non-trusted certificates automatically

Mac enable auto accepting non-trusted certs

Windows and Linux:Go to: File > Settings > Tools > Server Certificates >[x] Check on Accept non-trusted certificates automatically

Windows enable auto accepting non-trusted certs

I am using 2022.1 intellij version and the following steps solved my issue in a sec

File -> Setting -> Tools -> Server Certificates -> Check mark on "Accept non-trusted certificates automatically"thats it!!

To get rid of the pop up message go to below location and click on Accept non-trusted certificates automatically.

Below are for Windows, Linux and macOS

File | Settings | Tools | Server Certificates for Windows and Linux

IntelliJ IDEA | Preferences | Tools | Server Certificates for macOS

enter image description here