openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

demo code return unable to find valid certification path to requested target

Open yangfengKAUST opened this issue 2 years ago • 6 comments

I strictly followed the example code in my maven project, with the version of client of 0.10.0, but it gives me the error: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. I tried download the certificate of https://openai.com into my JVM, but it doesn't work either.

It seems that this error is at com.theokanning.openai.OpenAiService.createCompletion(OpenAiService.java:120).

image image

I update my pom with 0.10.0, this error happens as well. When calling apiCall.blockingGet(), it raise an error.

<dependency> <groupId>com.theokanning.openai-gpt3-java</groupId> <artifactId>service</artifactId> <version>0.10.0</version> </dependency>

image image image

yangfengKAUST avatar Feb 15 '23 01:02 yangfengKAUST

same

wangpuxia avatar Feb 15 '23 10:02 wangpuxia

Did this start happening on 0.10.0 or does this happen with previous versions?

TheoKanning avatar Feb 15 '23 14:02 TheoKanning

Did this start happening on 0.10.0 or does this happen with previous versions?

It happens on the maven project with 0.10.0 and on 0.9.0 as well. I tried again on few minutes ago, and this error repeats

yangfengKAUST avatar Feb 15 '23 14:02 yangfengKAUST

Can you please post results for:

java --version
gradle --version

Also, when you create your service, add a Duration.ofSeconds(50); // or whatever number you want.

There was a similar error previously where an older version of java had expired certificates which is where you would get the PKIX error. I think the solution is going to be to upgrade/reinstall the minor version of your java JVM/JDK and it'll fix the expired cert issues.

cryptoapebot avatar Feb 15 '23 15:02 cryptoapebot

gradle --version

Thanks. Since I used maven to build my project, it shows java version on 1.8.0_60, JDK 8 and maven version on 3.5.0. I tried the example code with the Duration param, it returns the exactly same error as above. Btw, which version / maven is recommend for this API, I can upgrade/reinstall ASAP

yangfengKAUST avatar Feb 15 '23 16:02 yangfengKAUST

I think you'll find if you upgrade your JDK to 1.8.0_202 (or higher) it'll fix your cert problem.

I'd strongly recommend using a JDK 11 through JDK 19 though as they include a massive amount of security fixes, performance improvements, and new implementations for networking, threading, streams, and other core features.

cryptoapebot avatar Feb 15 '23 16:02 cryptoapebot

I think you'll find if you upgrade your JDK to 1.8.0_202 (or higher) it'll fix your cert problem.

I'd strongly recommend using a JDK 11 through JDK 19 though as they include a massive amount of security fixes, performance improvements, and new implementations for networking, threading, streams, and other core features.

problem solved ! thank you !

wangpuxia avatar Feb 16 '23 01:02 wangpuxia

problem solved. cool.

yangfengKAUST avatar Feb 16 '23 15:02 yangfengKAUST