使用KeyczarTool创建新的键集

时间:2013-04-02 12:57:16

标签: encryption filenotfoundexception keyczar

按照wiki中提到的文档,我正在尝试使用KeyczarTool生成新的密钥集。有人遇到过这个FileNotFoundException吗? KeyczarTool.jar具有rwx权限并尝试通过sudo运行。

来自docs

Command Usage:
create --location=/path/to/keys --purpose=(crypt|sign) [--name="A name"] [--asymmetric=(dsa|rsa|ec)]
    Creates a new, empty key set in the given location.
    This key set must have a purpose of either "crypt" or "sign"
    and may optionally be given a name. The optional version 
    flag will generate a public key set of the given algorithm.
    The "dsa" and "ec" asymmetric values are valid only for sets
    with "sign" purpose.

Cmd:

$ java -jar KeyczarTool-0.71f-060112.jar create --location=/keys  --purpose=crypt -name="first key" --asymmetric=rsa   

输出:

org.keyczar.exceptions.KeyczarException: Unable to write to: /keys/meta 
    at org.keyczar.KeyczarTool.create(KeyczarTool.java:366)
    at org.keyczar.KeyczarTool.main(KeyczarTool.java:123)
Caused by: java.io.FileNotFoundException: /keys/meta (No such file or directory)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
    at org.keyczar.KeyczarTool.create(KeyczarTool.java:362)
    ... 1 more

2 个答案:

答案 0 :(得分:0)

使用当前版本的java keyczar,在运行程序之前,需要首先创建目录“keys”。

这是一个已知问题KeyczarTool should create directories automatically

答案 1 :(得分:0)

正如@jbtule所指出的那样,你必须首先创建密钥dir。但也包括。在斜线之前。

正确的工作指令是: $ java -jar KeyczarTool-0.71f-060112.jar create --location = ./ keys --purpose = crypt -name =“first key”--asymmetric = rsa