although the cert is included in Accepted certificates ,PKIX path building failed - ssl-certificate

I Use #Intellij idea .my program try to connect the #URL using a #HttpURLConnection.I face the error "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target"
After downloading the certificate from the browser, it is included in the accepted certificated in Intellij setting( File/setting/tools/server certificates) and also select the item " Accept non-trusted certificates automatically" at the top of the page.
Also the downloaded certificate is added successfully to #keystore through the command #keytool in #cmd administrator mode.( by the list command it can be seen correctly). I add the certificate to the #cacerts #keystore exactly to the JDK and JRE path mentioned in "build, execution and deployment" section in #Intellij idea setting.
when I debug the program, the added certificate is listed correctly in the #trustedCerts.
I appreciate your help and welcome any idea and tricks. Thanks in advance.

Related

Jenkins doesn't connect to Internet (SSL trouble)

Error message: SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I been trying to configure the proxy correctly but some http servers respond with success, meanwhile all the https doesn't.
I installed all the necessary plugins manually for run a sample pipeline but the error in console output is just a nested page 404 by jenkins.
It's important to know that my OS have the cli internet connection blocked for security terms.
This is the last followable trouble that I have, but I'm a little bit confusing with the SSL cert, I tried to resolve it by this post but is not clear to me which SSL cert I have to download and if this could cause troubles with my PC restrictions.
One solution to resolve this issue is change the update url at management plugins > advanced setting > url update from this
https://updates.jenkins.io/update-center.json
to this
http://updates.jenkins.io/update-center.json
this solutions is not definitive and i won't recommend it.
Actually i solve this problem loading the plugins.jenkins.io cert to the javas's keystore using
.\keytool.exe -import -alias {alias} -keystore %JAVA%\lib\security\cacerts -file \path\to\your\cert
(Be sure than you are not overwritting anything and the password for -import param by default is changeit)

Error when trying to connect to Anypoint Platform from Studio 7. There was a problem with the SSL handshake

Error when trying to connect to Anypoint Platform from Studio 7. There was a problem with the SSL handshake, please check your certificate installation
There was a problem with the SSL handshake, please check your certificate installation.
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I am stuck on this issue since month, please help..
Assuming you are using AnypointStudio 7.6.0, it comes with AdoptOpenJDK8 bundled. If not, install AdoptOpen JDK. Next, create a JAVA_HOME environment variable to point to your OpenJDK install location.
Use a browser to access https://anypoint.mulesoft.com/ and check the Certificate details in the "Certificate Path" tab. So at this point, follow the method that you used to install i.e. import not only Company Root CA certificate but also add Company Issuing CA Intranet Server certificate (this is the child of the Company Root CA) details to the stand-alone JVM that you installed. This is important for your Studio to work properly.
See some more details here: https://help.mulesoft.com/s/article/How-to-resolve-certification-error-when-performing-update-in-Studio

SSL cert works in SOAPUI but not in Jmeter2.13

I am testing client-server over secured connection.
I loaded keystore cert into SOAPUI and was able to connect to my server's component. However, when I configure the same keystore cert in JMeter v2.13, I am getting this error:
Response code: Non HTTP response code: javax.net.ssl.SSLHandshakeException
Response message: Non HTTP response message: >java.security.cert.CertificateException: Certificates does not conform to >algorithm constraints
I've referred to many suggestion found and have
configured the path to my keystore and password in Jmeter's system.properties and added the 'Keystore Configuration'
Can anyone shed light on this?
After searching for answer I found that the answer here. Potentially there's few installation in my local machine.
My issue was because I have java.security at the following directories:
C:\Program Files (x86)\Java\jre1.8.0_73\lib\security
C:\Program Files\Java\jdk1.8.0_101
C:\Program Files\Java\jre1.8.0_101\lib\security
So, I've editted the value in java.security of C:\Program Files\Java\jre1.8.0_101\lib\security and I was able to send SOAP over https.
Having solved the problem, I do hope someone is able to explain to me why my client looks for settings in JRE but not JDK.

leiningen: How do I turn off ssl verification?

I'm a first-time leiningen user on Windows. When I run lein run I get the following error:
C:\Users\me\clojure-app>lein run
Could not transfer artifact org.clojure:clojure:pom:1.7.0 from/to central (https://repo1.maven.org/maven2/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Could not transfer artifact org.clojure:tools.nrepl:pom:0.2.10 from/to central (https://repo1.maven.org/maven2/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Could not transfer artifact clojure-complete:clojure-complete:pom:0.2.3 from/to central (https://repo1.maven.org/maven2/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
This could be due to a typo in :dependencies or network issues.
If you are behind a proxy, try setting the 'http_proxy' environment variable.
My http_proxy and https_proxy environment variables are indeed set properly.
I'm behind a corporate firewall that re-signs web traffic with its own SSL certificates, which I suspected could be the root of my issues. However, I set my HTTP_CLIENT environment variable to:
curl --insecure -f -L -o
...to avoid SSL verification (as suggested by this note in the installation help) but that did not change the error message.
So, my root question, I suppose is: what steps must a user take to get lein run to successfully bring down dependencies on a Windows machine that is behind a corporate firewall that re-signs SSL traffic? :o)
Here are some options in inverse order of crazyness (least crazy first)
Add you companies proxy to your trust store, and don't do anything special in Leiningen that you will have to remember to do again the next time you change projects or computers. You may also need to add it to the Java JVM's certificate store in addition to the systems (this is very likely your problem)
Add you companies proxy certificate to the project's project.clj's :certificate section This way if the certificate needs to be changed than only one person needs to change it and the whole team will get the benefit.
Many companies have an internal caching maven proxy such as Nexus that will automatically fetch and cache dependencies and then make them quickly available to people inside the network. Find out if you have one of these by asking around or looking in .pom file on Java projects for the config.
Go home, or to a local coffee shop, download the dependencies, and then come back to the office. A walk and some fresh air is always good after dealing with TLS certs anyway.
Download the file manually, with your browser and put them in the .m2 directory yourself.
I'm really trying to not be snooty, by omitting an answer to your actual question. I do realize that there is not an option to disable security on this list. That's on purpose because one of there options will surely work and will make your life much better for knowing how to use these. If it still comes across as pretentious then please accept my most sincere apology along with the answer.
To elaborate on Arthur's answer and save a trip to google for the command:
To add the certificate to the JRE's truststore, use this keytool command:
keytool -import -trustcacerts -file CompanyMitmProxyCertificate.crt -alias ZScaler -keystore cacerts
Where: "CompanyMitmProxyCertificate.crt" is the certificate for your company's man-in-the-middle-attack cert and 'cacerts' is the keystore for your jre located under "\lib\security". The default password for the keystore is 'changeit'.

TeamCity and Mercurial https

I try to connect from TeamCity to Mercurial repository over https.
But I can't, because appears error:
stderr: abort: error: _ssl.c:577: error: 14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed.
How can I disable sertificate verification by TeamCity?
Or how I can workaround this?
I have tried to load sertificate from IE and past it in cer file of Mercurial, but it is not resolve my issue.
I resolve my issue, only after put mercurial.ini in catalog C:\Windows\System32\config\systemprofile.
Editing of .hgrc not take effect. Only putting mercurial.ini in C:\Windows\System32\config\systemprofile and add loaded certificate to cacept.pem solve my issue.
Better than disabling certificate verification (where possible) is to let Mercurial know that you trust the certificate. (This is a Windows-specific answer).
The thing I missed for ages is that even if you import the certificate into the Trusted Root Certification Authority, this doesn't affect the Local System account, which TeamCity is running under if you have set it up to run as a service.
The full steps to get the Local System account to trust a certificate are in this answer, but I'll reproduce them in brief here:
First, get a copy of the certificate. You can export this to a file from the all the main browsers.
Then, run mmc.exe from the start menu. Add the Certificates snap-in. If TeamCity is running as the local system account you want to manage "Local computer" certificates. If TeamCity is running as an ordinary user you want to manage user certificates.
Navigate to "Trusted Root Certification Authorities". Then click "Action > All Tasks > Import" and import the certificate file.
A final note: You can use psexec.exe from PSTools to run powershell as Local System and test things are working before going back to TeamCity: (Reference)
psexec -i -s Powershell.exe