clientkeystore 访问被拒绝

clientkeystore Access is denied

当我想使用 keytool 创建密钥库时,我收到一条访问被拒绝的错误消息。见下文

PS C:\Program Files\Java\jdk1.8.0_144\bin> .\keytool.exe -keystore clientkeystore -genkey -alias client
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  ...
What is the name of your organizational unit?
  [Unknown]:  ...
What is the name of your organization?
  [Unknown]:  ...
What is the name of your City or Locality?
  [Unknown]:  ...
What is the name of your State or Province?
  [Unknown]:  ...
What is the two-letter country code for this unit?
  [Unknown]:  ..
Is CN=..., OU=..., O=..., L=..., ST=..., C=.. correct?
  [no]:  yes

Enter key password for <client>
        (RETURN if same as keystore password):
Re-enter new password:
keytool error: java.io.FileNotFoundException: clientkeystore (Access is denied)
PS C:\Program Files\Java\jdk1.8.0_144\bin>

我该如何解决?

我能够在 JDK 1.8 上重现此问题。0_171 然后解决它。

基本上,您因写入文件而被拒绝访问:

C:\Program Files\Java\jdk1.8.0_144\bin\clientkeystore

您需要执行以下操作之一:

运行 来自您的主目录的命令并指定密钥库二进制文件的完整路径。

PS> cd $HOME;
PS> C:\Program Files\Java\jdk1.8.0_144\bin\keytool.exe -keystore clientkeystore -genkey -alias client

指定您具有写入权限的 clientkeystore 文件的路径。在此示例中,我使用的是您的主目录:

PS> cd C:\Program Files\Java\jdk1.8.0_144\bin
PS> .\keytool.exe -keystore $HOME\clientkeystore -genkey -alias client

(我会推荐这个)将 JDK bin 目录附加到您的 Path 环境变量,并指定您有权访问的目录:

PS> $env:Path += "C:\Program Files\Java\jdk1.8.0_144\bin"
PS> keytool.exe -keystore $HOME\clientkeystore -genkey -alias client

完成。