I am currently embedding Reddit OAuth2 login in my web application. Shaking hands and a token works fine when testing locally, but when starting on the server (located on the DIY OpenShift Cartridge), the following error occurs:
java.security.InvalidAlgorithmParameterException: Prime size must be multiple of 64, and can only range from 512 to 1024 (inclusive)
This is the result.
java.lang.RuntimeException: Could not generate DH keypair
I worked most of the day and found various solutions, from changing the Java version to using BouncyCastle. However, I use the Scribe library, so I don’t think I can implement BouncyCastle without overlaying and changing the scribe’s base, what kind of defeat it has in mind.
The JCE Unlimited Strength installation also appeared, but I can’t do it on OpenShift because there is no root access (maybe it can force one of their team to do this).
Used versions of java (taken from java -version ):
Local Test Machine:
java version "1.7.0_51" OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-1ubuntu1) OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
OpenShift Server:
java version "1.7.0_51" OpenJDK Runtime Environment (rhel-2.4.4.1.el6_5-i386 u51-b02) OpenJDK Server VM (build 24.45-b08, mixed mode)
I do not understand what I can do to solve this problem. I hope I'm stupid or don't understand something, so any possible solutions will be great!
-
EDIT 1
Request code that returns an error (using Scribe, as I mentioned, there may not be many). Token endpoint https://ssl.reddit.com/api/v1/access_token uses POST. As I said above, this works on my test machine.
OAuthRequest request = new OAuthRequest(getAccessTokenVerb(), getAccessTokenEndpoint()); request.addHeader("Authorization", "Basic" +Base64.encode((config.getApiKey()+":"+config.getApiSecret()).getBytes())); request.addBodyParameter("state", "none"); request.addBodyParameter(OAuthConstants.SCOPE, config.getScope()); request.addBodyParameter(OAuthConstants.CLIENT_ID, config.getApiKey()); request.addBodyParameter(OAuthConstants.REDIRECT_URI, config.getCallback()); request.addBodyParameter(OAuthConstants.CODE, verifier.getValue()); request.addBodyParameter("grant_type", "authorization_code"); Response response = request.send(); // Errors here from Request.createConnection in the Scribe code return getAccessTokenExtractor().extract(response.getBody());