c:\Windows\System32\java.exe default cert store location? - windows-7

I have not set java_home and I need to know where the c:\Windows\System32\java.exe file points to.
I have several JDKs and JREs on my system.
The reason is that I am trying to connect via SSL to some server and it works in Netbeans after I export the certificate in the appropriate JRE (which I can see via Netbeans options)
However, when I connect via command-line, I get an SSL error. I tried adding the certificate to all my JREs but I cannot get it to work. I think it is a problem that this Windows shortcut points to some place I overlooked.
Is there an easy way to find out which JRE is the default one?
[EDIT] Or rather I need to find the location of the default keystore in the default JRE.
[EDIT] My problem is elaborated below:
the following two give SSL error:
"c:\Program Files\Java\jre6\bin\java.exe" -cp myjar.jar mypackage.myclass
"c:\Program Files (x86)\Java\jre6\bin\java.exe" -cp myjar.jar mypackage.myclass
The following two work
"c:\Program Files\Java\jdk1.6.0_24\bin\bin\java.exe" -cp myjar.jar mypackage.myclass
"c:\Program Files (x86)\jdk1.6.0_24\bin\jre6\bin\java.exe" -cp myjar.jar mypackage.myclass
I have exported the certificate using all four commands:
"c:\Program Files\Java\jdk1.6.0_24\bin\bin\keytool.exe" -import -alias myalias -file mycertfile
"c:\Program Files (x86)\Java\jdk1.6.0_24\bin\bin\keytool.exe" -import -alias myalias -file mycertfile
"c:\Program Files\Java\jre6\bin\bin\keytool.exe" -import -alias myalias -file mycertfile
"c:\Program Files (x86)\Java\jre6\bin\bin\keytool.exe" -import -alias myalias -file mycertfile
So it seems that the keytool uses a different store than java.exe.
would appreciate some help on this.

I found the solution. Thanks to this link.
It mentioned the location of the keystore. Surprisingly it took a bit of Googling.
The location is jre6\lib\security\cacerts
so I had to use the following command to import the certificate:
keytool.exe -import -alias myalias -file mycertfile -keystore "c:\Program Files\Java\jre6\lib\security\cacerts"

You should look at the "Java Application Runtimes Setting" from the Java tab of the Java Control Panel.
http://download.oracle.com/javase/1.5.0/docs/guide/deployment/deployment-guide/jcp.html
From this tab, you can disable/enable any running version and you can see what is the current system JVM version...

Related

Getting "BCFKS KeyStore corrupted: MAC calculation failed." error

I have a jks file and when i run the command keytool -keystore db-ssl-truststore.jks -list , i get the error
keytool error: java.io.IOException: BCFKS KeyStore corrupted: MAC calculation failed.
It seems, that you created keystore in BCFS format using the Bouncy Castle library.
If you want to see it in human-readable format, you can specify -storetype, -provider and -providerpath options for keytool:
keytool -keystore keystore.bckfs -storetype BCFKS -providerpath "bc-fips-1.0.2.jar" -provider org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider -list -v

keytool error: java.io.FileNotFoundException: cacerts (Access is denied)

This question has been asked several times but none of the solutions work for me. I running the DOS command window as Administrator, but when running the keytool command to install a certificate I get the error above:
C:\Program Files\Java\jdk1.8.0_191\jre\lib\security>keytool -import -file xxx.yyy.zzz.crt -alias xxxx.yyy.zzz.com -keystore cacerts -storepass changeit -noprompt
Certificate was added to keystore
keytool error: java.io.FileNotFoundException: cacerts (Access is denied)
I'm on Windows 10 with JDK 1.8.0_191. Why would access be denied to the Administator?
I have faced the same issue.
Here is the solution what I found:
Copy the cacert file other than Java folder [May be D drive or desktop].
Update the path of cacert file path in your command [Sated in question].
Run your query. [You wont get the io exception].
Then replace the new cacert file in the original location.
"Run as administrator Command prompt" has fixed this issue at Windows.
My problem was that I did not have true admin rights to my Windows 10 laptop. I had enough permissions to install the JDK to the default location (which requires admin rights), but not enough rights to use keytool.
I uninstalled the JDK from the default location and reinstalled it in a directory that was not restricted to admin users. Then keytool worked properly.

Xamarin.Forms android application built from command line doesn't work

I have a Xamarin.Forms Android application, developed using Visual Studio 2017.
If I run/debug the application from Visual studio, with a USB device, it works well (both debug and release configurations).
I then create the .apk using the archive command in visual studio. To test it I simply upload it from my dev. computer to google drive and then download it from the same device and install it. This works as well.
The problem comes out when I try to create the .apk from the command line. The file obtained in this way is recognized by the device, which installs it correctly, but when I start the app, it seems to start but after a second it closes abruptly.
I don't even get the familiar popup "unofortunately the app stopped" that I got during the development phase when there were exceptions.
These are the commands I use:
msbuild /t:Clean /p:Configuration=Release
msbuild /t:PackageForAndroid /p:Configuration=Release
keytool -genkey -v -keystore SymCheck.keystore -alias SimCheck -keyalg
RSA -keysize 2048 -validity 10000
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore
SymCheck.keystore my_application.apk SimCheck
According to https://learn.microsoft.com/en-gb/xamarin/android/deploy-test/signing/manually-signing-the-apk
I also tried this sequence
msbuild /t:Clean /p:Configuration=Release
msbuild /t:PackageForAndroid /p:Configuration=Release
keytool -genkey -v -keystore SymCheck.keystore -alias SimCheck -keyalg
RSA -keysize 2048 -validity 10000
zipalign.exe -f -v 4 my_application.apk my_application_aligned.apk
apksigner.bat sign --ks SymCheck.keystore --ks-key-alias SimCheck
my_application_aligned.apk
with the same outcome.
I found the issue.
For some reasons the project option indicated below was set also in the release configuration.
When debugging, visual studio did transfer all the needed resources to the device, so everything worked fine in that case.
However, msbuild /t:PackageForAndroid was embedding in the .apk only part of the resources needed to run the application.
Removing that check did fix the problem; the .apk went from 3.6MB to 16MB.
So, here the full sequence of operations:
Ensure that Fast Deployment is disabled for the Release configuration
Open a Visual Studio command prompt on the directory where the .csproj is, then run the following commands in there:
# clean step
msbuild /t:Clean /p:Configuration=Release
# build step
msbuild /t:PackageForAndroid /p:Configuration=Release
# keytool step
"[c:\Program Files (x86)\Java\jdk1.8.0_161\bin\\]keytool.exe" -genkey -v -keystore <a filename for keystore> -alias {a string} -keyalg RSA -keysize 2048 -validity 10000
# jarsigner step
"[c:\Program Files (x86)\Android\android-sdk\build-tools\\{version e.g. 27.0.1}\\]zipalign.exe" -f -v 4 bin\Release\\{file apk created by msbuild in step build step} bin\Release\\{output apk filename}
# apksigner step
"[c:\Program Files (x86)\Android\android-sdk\build-tools\\{version e.g. 27.0.1}\\]apksigner.bat" sign --ks {filename for keystore chosen in step c.} --ks-key-alias {alias string chosen in keytool step.} bin\Release\\{output apk filename from zipalign step.}
The apk generated with last step (apksigner step) is the good one.
Paths in [] are platform specific and can be avoided changing the machine's PATH environment variable.
Parts in {} are names to be chosen by the user.

Error starting proxy server in Apache JMeter

When I attempt to start a proxy server in JMeter I'm presented with the following error:
could not create script recording proxy -see log for details: Command:'keytool -genkeypair alias :root_ca: -dname "CN=_DO NOT INSTALL unless this is your certificate (JMeter root CA), OU=Username: root, C=IE" -keyalg RSA -keystore proxyserver.jks -storepass {redacted -keypass {redacted) -validity 7 -ext bc:c' failed, code: 1
illegal option: -ext
Try keytool -help
My proxy configuration:
Any suggestions?
You can fix this by adding the 'Path to JDK' in your start up script (jmeter.bat) -
before invoking java.exe
if .%JM_LAUNCH% == . set JM_LAUNCH=java.exe
Try this for .bat file
Set JAVA_HOME= /path/to/JDK
Set PATH = %PATH%;%JAVA_HOME%/bin
if .%JM_LAUNCH% == . set JM_LAUNCH=java.exe
For .sh file,
export JAVA_HOME=/path/to/JDK
export PATH=$PATH:$JAVA_HOME/bin
java $JVM_ARGS -Dapple.laf.useScreenMenuBar=true -jar `dirname $0`/ApacheJMeter.jar "$#"

Record function in Jmeter results in a error message

I recently downloaded and installed Jmeter 2.11. afterwards I tried the record functionality of the program, but that resulted in an error message:
“Could not create script recording proxy – see log for detail”.
I have try modifying the “environment variables”, but that does not help.
In the Log from the application the following message was shown.
2014/08/19 10:23:02 WARN - jmeter.protocol.http.proxy.ProxyControl: Could not open/read key store C:\apache-jmeter-2.11\bin\proxyserver.jks (The system cannot find the file specified)
2014/08/19 10:23:02 INFO - jmeter.protocol.http.proxy.ProxyControl: Creating Proxy CA in C:\apache-jmeter-2.11\bin\proxyserver.jks
2014/08/19 10:23:02 ERROR - jmeter.protocol.http.proxy.ProxyControl: Could not initialise key store java.io.IOException: Command :'keytool -genkeypair -alias :root_ca: -dname "CN=_ DO NOT INSTALL unless this is your certificate (JMeter root CA), OU=Username: TATG, C=US" -keyalg RSA -keystore proxyserver.jks -storepass {redacted) -keypass {redacted) -validity 7 -ext bc:c' failed, code: 1
Illegal option: -ext
Try keytool -help
at org.apache.jorphan.exec.KeyToolUtils.genkeypair(KeyToolUtils.java:168)
at org.apache.jorphan.exec.KeyToolUtils.generateProxyCA(KeyToolUtils.java:230)
I notice the proxyserver.jks is missing under the bin directory.
How can I resolve this problem or get a copy of this file(ie. hack the directory)?
Read this, it answers exactly this issue:
https://wiki.apache.org/jmeter/TestRecording210

Resources