0

我想访问我的 Google 数据的数据馈送。我正在使用 gdata 私有库。如何使用 Java Keytool 生成 RSA-Key?如何将该密钥转换为 .pk8 格式?

4

1 回答 1

0

如何生成 RSA 密钥可以在 Google API 文档中找到:

http://code.google.com/intl/de-DE/apis/gdata/docs/auth/authsub.html#Registered

# Generate the RSA keys and certificate
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -sha1 -subj \
  '/C=US/ST=CA/L=Mountain View/CN=www.example.com' -keyout \
  myrsakey.pem -out /tmp/myrsacert.pem

使用 Java keytools 非常相似。

首先,生成密钥对:

keytool -genkey -alias myrsakey -keyalg RSA -validity 365 \
 -dname="CN=US, ST=CA/L=Mountain View, CN=www.example.com" \
 -keystore mykeystore.jks

然后就可以导出证书了:

keytool -keystore mykeystore.jks -export -alias myrsakey -rfc -file key.pem

AFAIK 私钥无法通过 keytool 直接导出。

于 2011-01-24T18:24:12.880 回答