Skip to content

Instantly share code, notes, and snippets.

@dominicthomas
Created October 22, 2013 20:24
Show Gist options
  • Save dominicthomas/7107509 to your computer and use it in GitHub Desktop.
Save dominicthomas/7107509 to your computer and use it in GitHub Desktop.
Generates a 2,048 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 10,000 days
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
@awwalasif
Copy link

Generating 2,048 bit RSA key pair and self-signed certificate (SHA384withRSA) with a validity of 10,000 days
for: CN=awwalasif, OU=awwalasif, O=awwalasif, L=noida, ST=UP, C=IN
[Storing my-upload-key.keystore]
keytool error: java.io.FileNotFoundException: my-upload-key.keystore (Access is denied)
java.io.FileNotFoundException: my-upload-key.keystore (Access is denied)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:289)
at java.base/java.io.FileOutputStream.(FileOutputStream.java:230)
at java.base/java.io.FileOutputStream.(FileOutputStream.java:118)
at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1372)
at java.base/sun.security.tools.keytool.Main.run(Main.java:419)
at java.base/sun.security.tools.keytool.Main.main(Main.java:412)

@last-hop
Copy link

same
Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
for: CN=aman singh, OU=aaaa, O=aaaa, L=aaaa, ST=aaa, C=IN
[Storing my-upload-key.keystore]
keytool error: java.io.FileNotFoundException: my-upload-key.keystore (Access is denied)
java.io.FileNotFoundException: my-upload-key.keystore (Access is denied)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:293)
at java.base/java.io.FileOutputStream.(FileOutputStream.java:235)
at java.base/java.io.FileOutputStream.(FileOutputStream.java:123)
at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1375)
at java.base/sun.security.tools.keytool.Main.run(Main.java:423)
at java.base/sun.security.tools.keytool.Main.main(Main.java:416)

@Dharmakrdas
Copy link

Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days
for: CN=Dharam Das, OU=2, O=Star, L=Gorakhpur, ST=UP, C="+91"
[Storing my-upload-key.keystore]
keytool error: java.io.FileNotFoundException: my-upload-key.keystore (Access is denied)
java.io.FileNotFoundException: my-upload-key.keystore (Access is denied)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:293)
at java.base/java.io.FileOutputStream.(FileOutputStream.java:235)
at java.base/java.io.FileOutputStream.(FileOutputStream.java:123)
at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:1375)
at java.base/sun.security.tools.keytool.Main.run(Main.java:423)
at java.base/sun.security.tools.keytool.Main.main(Main.java:416)

@Dharmakrdas
Copy link

I found a solution for this. Open the terminal in the specified path, like:

C:\Program Files\Java\jdk-17\bin>
Save the keystore to a folder where you have full permissions, and run the following command:

powershell
& "C:\Program Files\Java\jdk-17\bin\keytool.exe" -genkeypair -v -storetype PKCS12 -keystore "C:\Users\Dharam\my-upload-key.keystore" -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

This worked successfully on my system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment