score:48
Probably you want to import a "fake" SSL cert in JRE's trustcacerts for avoiding not-a-valid-certificate issues. Isn't it?
As Jon said, you can do the job with keytool:
keytool
-import
-alias <provide_an_alias>
-file <certificate_file>
-keystore <your_path_to_jre>/lib/security/cacerts
Use "changeit" as the default password when asked (thanks Brian Clozel). Ensure to use this runtime at your server or launch configuration.
score:0
You should probably create the certificate and import it into the default keystore using keytool. I'm not sure what you're trying to do with your application, but it should then be able to use that certificate.
score:0
sudo keytool -import -file /Users/balaji-pt2176/Desktop/Apple\ Worldwide\ Developer\ Relations\ Certification\ Authority.cer -keystore /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/jre/lib/security/cacerts
in mac
score:1
If you have default Java setup and have provided Java classpath, then you must be using Java Truststore for SSL certificates.
For this you can follow below steps to import certificates into Trust store:
- Navigate to the JRE\bin folder of your Java setup Ideally the path should be:
user\Java\jre1.8.0_221\bin
- You will be able to find Keytool in the bin folder(which will be used to run the commands):
- Now once you are on this path, open the path in your CMD prompt:
- Now you will be able to find default Trust store of Java at below path: Path-
user\Java\jre1.8.0_221\bin
Path to Java default Trust store
Now you can run below command to see contents of this Trust store:
keytool -list -v -keystore "C:\Program Files\Java\jre1.8.0_221\lib\security\cacerts"
Note: If your path to Trust store has spaces in it, then you need to use double quotes for the path. Else you can provide path like below:
keytool -list -v -keystore C:\Temp\Java\jre1.8.0_221\lib\security\cacerts
Now just provide password to Trust Store(Default password is: changeit): Accessing Trust store using Keytool
You can now as per your need add any certificate to the Trust store:
JRE_HOME/bin/keytool -import -trustcacerts -alias certAlias -file certFile -keystore trustStoreFile
score:2
We need to import a certificate means we need to use :
keytool
-importcert
-file <certificate_location>
-keystore <jre_location\lib\security\cacerts>
-alias "<cert_name>"
It will ask for a password. Type the password as changeit
Type Password : changeit
finally it will ask need to add {yes/no} :
type yes.
Note: Don't give blank space in location path
score:2
Mac
- Open Keychain Access.app (Shortcut: press Command + Spacebar and type Keychain)
- Search the desired certificate file (e.g.
example.cer
) and right-click ➡️ Select Export... ➡️ Save it to some location e.g.Desktop
. - Follow the instructions in this answer to import it to your Java certificate store. The important commands are:
cd $JAVA_HOME/lib/security
sudo cp cacerts cacerts.bak
sudo keytool -importcert -alias youralias -file ~/Desktop/example.cer -keystore cacerts
The default password of the keystore is: changeit
.
- Assuming,
$JAVA_HOME/lib/security
points to/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/lib/security
in your system, add the following lines in theeclipse.ini
file:
-Djavax.net.ssl.trustStore=/Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home/lib/security/cacerts
-Djavax.net.ssl.trustStorePassword=changeit
Note: If you are using STS, follow this answer to locate the .ini
file.
- Restart Eclipse.
score:8
There's a better tool for the job.
When you run (run as administrator in windows in order to save changes to system, sudo in linux, etc.) the application (it has installers for win/mac/linux) there's a built-in function to edit the system's cacerts file:
File -> Open Special -> Open CA Certificates
EITHER you already have the certificate file and you can go to:
Tools -> Import Trusted Certificate
OR you need to download the certificate from the server; go to:
Examine -> Examine SSL
From there type in the hostname and click ok. It will pop up a window showing the certificate details. At the bottom of that window there's an "Import" button that will allow you to directly import it into the cacerts.
Make sure you save and close cacerts, and restart your eclipse/application for the settings to take effect.
score:27
In case you have the certificate already in your Windows' certificate store (this is common in corporate/company deployments with MITM certificates), you can also use the following steps (with help from another Stackoverflow answer with more detailed explaination):
Locate the
eclipse.ini
file in your Eclipse installation and open itBelow the line
-vmargs
, add the following lines, then save the file:
-Djavax.net.ssl.trustStore=NUL
-Djavax.net.ssl.trustStoreType=Windows-ROOT
- Restart eclipse.
Source: stackoverflow.com
Related Query
- Importing SSL Certificate into Eclipse
- 'Must Override a Superclass Method' Errors after importing a project into Eclipse
- Importing Maven project into Eclipse
- Importing a GitHub project into Eclipse
- Importing a Maven project into Eclipse from Git
- Importing JSON into an Eclipse project
- Missing AndroidManifest.xml when importing an old Android project into Eclipse
- How to build and run Maven projects after importing into Eclipse IDE
- Importing a CMake project into Eclipse CDT
- Importing multiple projects into eclipse
- Maven root pom.xml marked as red when importing existing project into eclipse
- Problem importing Android project archives into Eclipse
- Invalid project description when importing project into Eclipse
- difficulty in importing the facebook-android-sdk into eclipse
- Trouble importing android.support.v7.widget.CardView into Eclipse
- Importing code style formatting settings into eclipse from intellij-idea
- Importing existing java dynamic web project into Eclipse
- Importing multiple maven projects from git into eclipse
- Programmatically importing an existing project into Eclipse
- Null Pointer Importing Gradle Project Into Eclipse
- Problems importing an Android project into Eclipse
- Importing Existing Android Project into Eclipse
- How to copy projects into workspace of eclipse after importing the project?
- Importing an existing maven Project into Eclipse
- Importing an existing Eclipse project into MyEclipse workspace
- Project Name Issue when Importing Android Projects into Eclipse
- After importing into eclipse using eGit, can't compile and run. What do I do?
- Error on importing an Eclipse project into Android Studio
- Importing projects into eclipse only imports Android projects
- Importing Actionbarsherlock into eclipse
More Query from same tag
- Data lost on Restart of Eclipse
- How to deploy war file to production glass fish server
- Run time exception (Java Version Issue)
- Eclipse does not remember external source attachments
- EL tag not working with maven in tomcat 7
- How to add an executable jar file to my project in Eclipse?
- How to insert and Retrieve for capture image in android sqlite database
- Cannot edit Android Manifest file in Eclipse
- Netbeans and Eclipse doesn't show modal window and locks itself on MAC
- CXF - Wsdl2Java enable to access to xml.xsd
- Customization Failed In Eclipse
- Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException
- Tried Euler's #14 again with recursion, didn't work for me. SPOILERS EULER 14th
- How to know the No. of java files in my workspace in Eclipse?
- Importing libraries with parameters writen in Python to Robot framework in Eclipse
- Eclipse doesn't create Main Activity and layout
- Which IDE for C++ Development on Windows 8?
- Is Generics syntax removed at compile time in Java?
- Allocation of temp directory inside tomcat installation base results in error due to read only property
- com.google.android.gms.ads.AdView not found
- How do I make the default bin directory visible in Eclipse?
- Error parsing XML:mismatched tag/ Button cannot be resolved to a type
- How to change API level from 15 to 16 in eclipse
- Java Dynamic Web project with Maven and Eclipse
- Why doesn't Eclipse recognize import java.JOptionPane?
- Not able to debug android project in eclipse
- R cannot be resolved to a variable eclipse android
- IBM Worklight 6.1 - Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES] - signed apk
- ViewsPlugin.class is missing in this org.eclipse.ui.views_3.9.0.v20170226-1833.jar Plugin
- java.lang.ClassNotFoundException: oracle.jdbc.driver.OracaleDriver