CodeGPT icon indicating copy to clipboard operation
CodeGPT copied to clipboard

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Open MomenDev opened this issue 10 months ago • 15 comments

What happened?

image always something wrong with this log, but this custom service can work on other plugin.

Relevant log output or stack trace


javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321)
	at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:316)
	at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:654)
	at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:473)
	at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:369)
	at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)
	at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480)
	at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458)
	at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201)
	at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172)
	at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1510)
	at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1425)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455)
	at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426)
	at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:379)
	at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
	at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
	at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
	at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
	at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
	at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439)
	at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306)
	at java.base/sun.security.validator.Validator.validate(Validator.java:264)
	at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
	at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)
	at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:638)
	... 31 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
	at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:148)
	at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:129)
	at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
	at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434)
	... 36 more

Steps to reproduce

always something wrong with this log

CodeGPT version

2.6.2-222

Operating System

Windows

MomenDev avatar Apr 19 '24 11:04 MomenDev

Did you enable proxy settings? Could it be that your IntelliJ is very old? Maybe you could try it with the current 2024.1 first?

Otherwise, can you try downloading the certificate (for example with Firefox / Tools / Page Info) and add it to IntelliJ Settings / Tools / Server Certificates? https://stackoverflow.com/questions/74356366/intellij-ide-giving-pkix-path-building-failed-sun-security-provider-certpath-su#answer-76222569

reneleonhardt avatar Apr 19 '24 16:04 reneleonhardt

Did you enable proxy settings? Could it be that your IntelliJ is very old? Maybe you could try it with the current 2024.1 first?

I upgrade the IntelliJ version to 2024.1, but but the issue is still happening.

Otherwise, can you try downloading the certificate (for example with Firefox / Tools / Page Info) and add it to IntelliJ Settings / Tools / Server Certificates? https://stackoverflow.com/questions/74356366/intellij-ide-giving-pkix-path-building-failed-sun-security-provider-certpath-su#answer-76222569

I'm not sure which certificate to download. I've tried several possible certificates, but they all fail.

MomenDev avatar Apr 22 '24 10:04 MomenDev

Does someone have Windows to reproduce this? 😅 CodeGPT 2.6.3 looks a bit different, but there is a valid response with and without API Key.

Bewildcard response

If you want to try you could download an Ubuntu Linux image 🙂 https://ubuntu.com/download/desktop https://www.virtualbox.org/wiki/Download_Old_Builds_7_0 https://www.jetbrains.com/toolbox-app/

reneleonhardt avatar Apr 23 '24 05:04 reneleonhardt

I am facing same issue, is there anyway we can disable cert validation?

nmvijay avatar May 02 '24 07:05 nmvijay

I've add certificate to IntelliJ Settings / Tools / Server Certificates but anyway have the same issue.

olegatord avatar May 08 '24 14:05 olegatord

Hello, same issue on my side. I use a self signed certificate for testing purposes, and didn't succeed to bypass the certificate validation.

I tried two solutions without success :

  • add the certificate in Intellij (File -> Tools -> Server Certificates)
  • add the certificate in the JRE keystore (%JAVA_HOME%/bin/keytool -importcert -file certificate.cer -keystore keystore.jks -alias "Alias")

banalg avatar May 18 '24 20:05 banalg

Hello, same issue on my side.

DataGrip or Pycharm, the lastest version installed through Jetbrains Toolbox. CodeGPT: 2.8.x OS: Windows 11

javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:378) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:321) at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:316) at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:654) at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:473) at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:369) at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396) at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480) at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458) at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:201) at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172) at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1510) at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1425) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426) at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:379) at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337) at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:840) Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439) at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306) at java.base/sun.security.validator.Validator.validate(Validator.java:264) at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231) at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132) at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:638) ... 31 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:148) at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:129) at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297) at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434) ... 36 more

alexwwang avatar Jul 17 '24 06:07 alexwwang

Hi, did anyone found a way around this issue? Adding the certificate in IntelliJ (or the JVM) and accepting non-trusted certificates didn't help either. In my corporate setting, we are behind ZScaler, and although adding its certificate in other tools works, even in Intellij, oddly for this plugin it doesn't… 🤔

cebbec avatar Aug 27 '24 09:08 cebbec

I have the same issue, does anyone have a workaround for this issue?

voku avatar Aug 29 '24 09:08 voku

Unfortunately, I have no easy way of reproducing it myself. Some people have noted that adding the certificate to their JRE has worked, while others say it hasn't.

As far as I know, the certificate is obtained from the bundled JetBrains JRE, and e.g. for macOS, it would be here: /Applications/IntelliJ IDEA.app/Contents/jbr/Contents/Home/lib/security. However, for Toolbox users, I believe the JRE is in a different location.

EDIT: Or there might be even a chance that you've reconfigured the IDE boot runtime.

Screenshot 2024-08-29 at 12 33 54

carlrobertoh avatar Aug 29 '24 09:08 carlrobertoh

I thought I had imported the certificate in the right JRE, but I looked into the Toolbox installation directory as you suggested and found the right path, which was for me on Windows : C:\Users\%userprofile%\AppData\Local\Programs\IntelliJ IDEA Ultimate\jbr\lib\security Thanks @carlrobertoh, I'm going to enjoy using CodeGPT at work too.

cebbec avatar Aug 29 '24 10:08 cebbec

Glad it helped! I need to document this issue better.

carlrobertoh avatar Aug 29 '24 10:08 carlrobertoh

@cebbec How did you import the additional certificates into the new directory?

voku avatar Aug 29 '24 12:08 voku

I used this command : keytool -import -trustcacerts -alias zscaler -file "C:\Users\…\Zscaler Root CA.crt" -keystore C:\Users\%userprofile%\AppData\Local\Programs\IntelliJ IDEA Ultimate\jbr\lib\security\cacerts It isn't a directory, but a keystore, the one used by the JVM running Intellij.

cebbec avatar Aug 29 '24 13:08 cebbec

Can anyone help with the same problem on PyCharm Community edition (latest) Running on MacOS

Where do I download the certificate and where to install it?

mosheeshel avatar Sep 24 '24 14:09 mosheeshel

Note: an upgrade of Intellij fails if cacerts file is updated. So importing the ca cert manually is a workaround, not a fix.

afunix avatar Oct 27 '24 21:10 afunix