Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

oauth Token ,error: Short read of DER length

jacob delddd
Contributor
August 29, 2018

Following the tutorial on https://developer.atlassian.com/server/jira/platform/oauth/ i managed get till step 2. 

Running :

java -jar OAuthTutorialClient-1.0.jar requestToken 

 gave me this error:

C:\tutorial 0auth\java\target>java -jar OAuthTutorialClient-1.0.jar requestToken
java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException : Short read of DER length
at sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:217)
at java.security.KeyFactory.generatePrivate(KeyFactory.java:372)
at com.atlassian.oauth.client.example.JiraOAuthTokenFactory.getPrivateKey(JiraOAuthTokenFactory.java:92)
at com.atlassian.oauth.client.example.JiraOAuthTokenFactory.getOAuthRsaSigner(JiraOAuthTokenFactory.java:76)
at com.atlassian.oauth.client.example.JiraOAuthTokenFactory.getTemporaryToken(JiraOAuthTokenFactory.java:62)
at com.atlassian.oauth.client.example.JiraOAuthClient.getAndAuthorizeTemporaryToken(JiraOAuthClient.java:36)
at com.atlassian.oauth.client.example.OAuthClient.handleGetRequestTokenAction(OAuthClient.java:69)
at com.atlassian.oauth.client.example.OAuthClient.execute(OAuthClient.java:51)
at com.atlassian.oauth.client.example.ClientMain.main(ClientMain.java:18)
Caused by: java.security.InvalidKeyException: IOException : Short read of DER length
at sun.security.pkcs.PKCS8Key.decode(PKCS8Key.java:352)
at sun.security.pkcs.PKCS8Key.decode(PKCS8Key.java:357)
at sun.security.rsa.RSAPrivateCrtKeyImpl.<init>(RSAPrivateCrtKeyImpl.java:91)
at sun.security.rsa.RSAPrivateCrtKeyImpl.newKey(RSAPrivateCrtKeyImpl.java:75)
at sun.security.rsa.RSAKeyFactory.generatePrivate(RSAKeyFactory.java:316)
at sun.security.rsa.RSAKeyFactory.engineGeneratePrivate(RSAKeyFactory.java:213)
... 8 more

 Saddly i seem to be the only one. 

jira\_privatekey is named jira_privatekey in my folder, other than that i can't seem to find any differences

image.pngalso creating the keys didn't gave me any problems:

C:\tutorial 0auth\java\target>openssl genrsa -out jira_privatekey.pem 1024
Loading 'screen' into random state - done
Generating RSA private key, 1024 bit long modulus
................++++++
.....++++++
e is 65537 (0x10001)

C:\tutorial 0auth\java\target>openssl req -newkey rsa:1024 -x509 -key jira_privatekey.pem -out jira_publickey.cer -days 365
Loading 'screen' into random state - done
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:be
State or Province Name (full name) [Some-State]:we
Locality Name (eg, city) []:ie
Organization Name (eg, company) [Internet Widgits Pty Ltd]:eb
Organizational Unit Name (eg, section) []:eb
Common Name (e.g. server FQDN or YOUR name) []:a
Email Address []:ja

C:\tutorial 0auth\java\target>openssl pkcs8 -topk8 -nocrypt -in jira_privatekey.pem -out jira_privatekey.pcks8

C:\tutorial 0auth\java\target>openssl x509 -pubkey -noout -in jira_publickey.cer > jira_publickey.pem

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events