Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DerInputStream.getLength(): lengthTag=118, too big.

ANSWERED

Recently my application cannot retrieve the authorization keys from fitbit. Is there any changes that I need to do ?

These are the urls we are using

 

Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Could not parse key values
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:190)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1747)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1708)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1691)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1222)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1199)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.jav...
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1031)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
at com.fitbit.api.client.http.HttpClient.httpRequest(HttpClient.java:434)
... 191 more
Caused by: java.lang.RuntimeException: Could not parse key values
at sun.security.pkcs11.P11Key$P11ECPublicKey.fetchValues(P11Key.java:1000)
at sun.security.pkcs11.P11Key$P11ECPublicKey.getW(P11Key.java:1021)
at com.sun.net.ssl.internal.ssl.ECDHClientKeyExchange.<init>(ECDHClientKeyExchange.java:40)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:782)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:241)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:943)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1215)
... 197 more
Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=118, too big.
at sun.security.util.DerInputStream.getLength(DerInputStream.java:544)
at sun.security.util.DerValue.init(DerValue.java:347)
at sun.security.util.DerValue.<init>(DerValue.java:277)
at sun.security.pkcs11.P11Key$P11ECPublicKey.fetchValues(P11Key.java:991)

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

this had nothing to do with the fitbit api. I looks like out admins pushed changes and we needed to restart our application servers.

View best answer in original post

Best Answer
0 Votes
5 REPLIES 5

Can you please post your code. It's very hard to say for sure by stacktrace you posted, although to be honest it looks very weird as if you were using wrong functionality to encode/decode keys.

Ivan Bahdanau
Senior Software Developer at Fitbit
Best Answer
0 Votes

this code worked for us for about 3 years. Starting end of July I cannot extract the keys from your side. 

 

We did not, repeat not, push any changes to this app.

Best Answer
0 Votes

BTW this is the top part of that stack.

 

[#|2014-08-14T09:51:34.588-0500|INFO|sun-appserver2.1.1|javax.enterprise.system.stream.out|_ThreadID=36;_ThreadName=httpSSLWorkerThread-50002-4;|com.fitbit.api.FitbitAPIException: java.lang.RuntimeException: Could not parse key values
at com.fitbit.api.client.http.HttpClient.httpRequest(HttpClient.java:473)
at com.fitbit.api.client.http.HttpClient.getOauthRequestToken(HttpClient.java:169)
at com.fitbit.api.client.FitbitApiClientAgent.getOAuthTempToken(FitbitApiClientAgent.java:151)
at com.fitbit.api.client.service.FitbitAPIClientService.getResourceOwnerAuthorizationURL(FitbitAPIClientService.java:83)
at com.ui.action.FitbitAction.process(TestFitbitAction.java:82)

...

 

Best Answer
0 Votes

Let me know what you think! PM if want the keys we are using.

It looks like the synching the steps works but I cannot get the authorization keys for new users. Something is going on. 

 

 

public class FitbitAction extends WellnessAction
{
private static FitbitAPIEntityCache entityCache = new FitbitApiEntityCacheMapImpl();
private static FitbitApiCredentialsCache credentialsCache = new FitbitApiCredentialsCacheMapImpl();
private static FitbitApiSubscriptionStorage subscriptionStore = new FitbitApiSubscriptionStorageInMemoryImpl();
private String apiBaseUrl;
private String fitbitSiteBaseUrl;
private String clientConsumerKey;
private String clientSecret;

public static final String OAUTH_TOKEN = "oauth_token";
public static final String OAUTH_VERIFIER = "oauth_verifier";

private final static Log log = LogFactory.getLog( FitbitProviderDelegateImpl.class );

public String process()
{
APIResourceCredentials resourceCredentials = null;
try
{
ProviderDelegate providerDelegate = ProviderDelegateFactory.getInstance(); // Gets FITBIT impl
LocalUserDetail localUserDetail = new LocalUserDetail( "-" );
FitbitProvider fp = (FitbitProvider)providerDelegate.getProvider();

apiBaseUrl = "api.fitbit.com";
fitbitSiteBaseUrl = "http://www.fitbit.com";

clientConsumerKey = fp.getConsumerKey().trim();
clientSecret = fp.getConsumerSecret().trim();

 

FitbitApiClientAgent fitbitClientAgent = new FitbitApiClientAgent( apiBaseUrl, fitbitSiteBaseUrl, credentialsCache );

FitbitAPIClientService<FitbitApiClientAgent> apiClientService = new FitbitAPIClientService<FitbitApiClientAgent>( fitbitClientAgent,
clientConsumerKey, clientSecret, credentialsCache, entityCache, subscriptionStore );

FitbitAccount fitbitAccount = (FitbitAccount)providerDelegate.loadAccount( UserManager.getParticipantId() );

//
//
// Go get User persmission from www.fitbit.com to pull data down to our app
//
boolean noAccount = ( fitbitAccount == null || fitbitAccount.getTokenOne() == null || fitbitAccount.getTokenTwo() == null );
if ( noAccount && getServletRequest().getParameter( "completeAuthorization" ) == null )
{
String theDomain = getServletRequest().getRequestURL().toString();
theDomain = theDomain.substring( 0, theDomain.indexOf( "/wellness/" ) );

getServletResponse().sendRedirect(
apiClientService
.getResourceOwnerAuthorizationURL( localUserDetail, theDomain + "/wellness/fitbit/fb.action?completeAuthorization=Y" ) );
return null;
}

...
}

Best Answer
0 Votes

this had nothing to do with the fitbit api. I looks like out admins pushed changes and we needed to restart our application servers.

Best Answer
0 Votes