问题
When I use keytool to generate a key with ECC, I get this error:
Error keytool: java.security.NoSuchAlgorithmException: EC KeyPairGenerator not available
Then syntax used to generate a key is:
keytool -genkey -alias testing -keyalg EC -keysize 256 -keystore try.jks -dname "CN=localhost,OU=dep,O=lks,L=ny,ST=ny,C=USA"
I have this Java version:
openjdk version "1.8.0_60"
OpenJDK Runtime Environment (build 1.8.0_60-b16)
OpenJDK 64-Bit Server VM (build 25.60-b16, mixed mode)
回答1:
I had the same error with pepk (Play Encrypt Private Key)
on Ubuntu 16.04.
I solved this with a solution close to CipherX's answer:
- Download Java Oracle (tar.gz)
- Extract the files
- Instead of launching
java
installed on the sytem, launchjava
from the extracted files:
~/Downloads/android/jdk-9.0.1/bin/java -jar pepk.jar --keystore=acme.keystore \
--alias=acme --output=encrypted_private_key_path --encryptionkey=eb…
And the Error: EC KeyPairGenerator not available
error disappeared.
回答2:
This error indicates that your EC security provider is missing, please do the following to add it:
- Edit the file "jdk1.8.0_65\lib\security\java.security"
- Search for "List of providers and their preference order"
- Add "security.provider.[Last security provider id +1]=sun.security.ec.SunEC" to the list of security providers.
see this link for more details about the sunEC security provider.
回答3:
I resolved the problem reading this article (linked by the user @QuakeCore). If anyone have this problem you can resolve following my steps:
- Download Java Oracle (tar.gz);
- Copy the file
jdk1.8.0_*/jre/lib/amd64/libsunec.so
from extracted folder to/usr/lib/jvm/java-1.8.0-openjdk.x86_64/jre/lib/amd64/libsunec.so
; - Use the syntax written in my original question to generate the key.
来源:https://stackoverflow.com/questions/40957280/keytool-ec-keypairgenerator-not-available