TritonDataCenter / java-http-signature

Library for performing RSA signed HTTP requests in Java
Mozilla Public License 2.0
17 stars 13 forks source link

Gracefully drop to support non-native modpow operations when libgmp is not available #33

Closed dekobon closed 7 years ago

dekobon commented 7 years ago

In some configurations, we get this error when making the first request against Manta:

java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: SHA256withNativeRSA, provider: native-rsa, class: com.joyent.manta.http.signature.crypto.NativeRSAWithSHA$SHA256)
com.joyent.manta.http.signature.CryptoException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: SHA256withNativeRSA, provider: native-rsa, class: com.joyent.manta.http.signature.crypto.NativeRSAWithSHA$SHA256)
    at com.joyent.manta.http.signature.Signer.<init>(Signer.java:117)
    at com.joyent.manta.http.signature.Signer$Builder.build(Signer.java:609)
    at com.joyent.manta.http.signature.ThreadLocalSigner.initialValue(ThreadLocalSigner.java:80)
    at com.joyent.manta.http.signature.ThreadLocalSigner.initialValue(ThreadLocalSigner.java:22)
    at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:180)
    at java.lang.ThreadLocal.get(ThreadLocal.java:170)
    at com.joyent.manta.http.signature.apache.httpclient.HttpSignatureAuthScheme.signRequestHeader(HttpSignatureAuthScheme.java:198)
    at com.joyent.manta.http.signature.apache.httpclient.HttpSignatureAuthScheme.authenticate(HttpSignatureAuthScheme.java:161)
    at com.joyent.manta.http.signature.apache.httpclient.HttpSignatureRequestInterceptor.process(HttpSignatureRequestInterceptor.java:66)
    at com.joyent.manta.org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:133)
    at com.joyent.manta.org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:183)
    at com.joyent.manta.org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at com.joyent.manta.org.apache.http.impl.execchain.ServiceUnavailableRetryExec.execute(ServiceUnavailableRetryExec.java:85)
    at com.joyent.manta.org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
    at com.joyent.manta.org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at com.joyent.manta.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at com.joyent.manta.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
    at com.joyent.manta.http.StandardHttpHelper.executeRequest(StandardHttpHelper.java:438)
    at com.joyent.manta.http.StandardHttpHelper.executeAndCloseRequest(StandardHttpHelper.java:424)
    at com.joyent.manta.http.StandardHttpHelper.executeAndCloseRequest(StandardHttpHelper.java:415)
    at com.joyent.manta.http.StandardHttpHelper.httpHead(StandardHttpHelper.java:101)
    at com.joyent.manta.client.MantaClient.head(MantaClient.java:656)
    at com.joyent.manta.cli.MantaCLI.connectTest(MantaCLI.java:188)
    at com.joyent.manta.cli.MantaCLI.main(MantaCLI.java:72)
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: SHA256withNativeRSA, provider: native-rsa, class: com.joyent.manta.http.signature.crypto.NativeRSAWithSHA$SHA256)
    at java.security.Provider$Service.newInstance(Provider.java:1617)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
    at sun.security.jca.GetInstance.getInstance(GetInstance.java:218)
    at java.security.Signature.getInstance(Signature.java:405)
    at com.joyent.manta.http.signature.Signer.<init>(Signer.java:115)
    ... 23 more
Caused by: java.lang.NoClassDefFoundError: com/squareup/jnagmp/GmpInteger
    at com.joyent.manta.http.signature.crypto.NativeRSABlindedEngine.<init>(NativeRSABlindedEngine.java:58)
    at com.joyent.manta.http.signature.crypto.NativeRSAWithSHA$SHA256.<init>(NativeRSAWithSHA.java:75)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.security.Provider$Service.newInstance(Provider.java:1595)
    ... 27 more
Caused by: java.lang.ClassNotFoundException: com.squareup.jnagmp.GmpInteger
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 34 more

We should just output a warning and drop to using the default Java RSA implementation.

dekobon commented 7 years ago

Issue has been moved to: https://github.com/joyent/java-manta/issues/287