Hi there people
A problem I'm facing today looks like that issue:
http://groups.google.com/group/jets3t-users/browse_thread/thread/995cf6bd83f6be8c
but unlink in that issue, I have linux (opensuse 11.2) and converting
the key to der format before importing it does not seem to do
anything, after reading the new converted key file, the same exact
issue appears, which leads me to belive the problem I'm facing is
different form that of the author of the previous thread.
The script I used to import the PEM key:
byte[] derPrivateKey = EncryptionUtil.convertRsaPemToDer(
new FileInputStream("/home/work2/parts/cloudfront/pk-
xxxxxxxxxxxxxx.pem"));
The script I used to import DER key:
File privKeyFile = new File("/home/work2/parts/cloudfront/pk-
xxxxxxxxxxxxxx.der");
DataInputStream dis = new DataInputStream(new
FileInputStream(privKeyFile));
byte[] derPrivateKey = new byte[(int)privKeyFile.length()];
dis.read(derPrivateKey);
dis.close();
And the openssl script I used to convert the file type:
openssl rsa -in pk-xxxxxxxxxxxxxx.pem -inform PEM -out pk-
xxxxxxxxxxxxxx.der -outform DER
The full stack trace is:
Exception in thread "main"
org.jets3t.service.CloudFrontServiceException:
java.security.spec.InvalidKeySpecException:
java.security.InvalidKeyException: IOException : algid parse error,
not a sequence
at
org.jets3t.service.CloudFrontService.signUrlCanned(CloudFrontService.java:
2145)
at Lunch.main(Lunch.java:57)
Caused by: java.security.spec.InvalidKeySpecException:
java.security.InvalidKeyException: IOException : algid parse error,
not a sequence
at
sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:
200)
at java.security.KeyFactory.generatePrivate(KeyFactory.java:342)
at
org.jets3t.service.security.EncryptionUtil.signWithRsaSha1(EncryptionUtil.java:
526)
at
org.jets3t.service.CloudFrontService.signUrlCanned(CloudFrontService.java:
2131)
... 1 more
Caused by: java.security.InvalidKeyException: IOException : algid
parse error, not a sequence
at sun.security.pkcs.PKCS8Key.decode(PKCS8Key.java:344)
at sun.security.pkcs.PKCS8Key.decode(PKCS8Key.java:350)
at
sun.security.rsa.RSAPrivateCrtKeyImpl.<init>(RSAPrivateCrtKeyImpl.java:
74)
at
sun.security.rsa.RSAPrivateCrtKeyImpl.newKey(RSAPrivateCrtKeyImpl.java:
58)
at sun.security.rsa.RSAKeyFactory.generatePrivate(RSAKeyFactory.java:
299)
at
sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:
196)
... 4 more