dcm4che / dcm4chee-arc-light

DICOM Archive J2EE application
430 stars 236 forks source link

Add option to enable signature v4 for aws s3 #1401

Open jardakotesovec opened 6 years ago

jardakotesovec commented 6 years ago

Both available S3 storages use V2 signature and there is no option to switch it to v4 which is required by some regions.

jclouds supports v4 since 1.9.0 version, but I could not figure out how to force it from dcm4chee configuration.

Would be awesome either extend wiki if its somehow already possible to set it or make it configurable in future versions.

Any feedback appreciated.

ngutman commented 3 years ago

@gunterze After digging a bit around jclouds S3 v4 signature support - it seems like the only thing needed is to change the provider s3 to aws-s3 in the dcmURI storage schema, for example -

dcmURI: jclouds:aws-s3:https://s3-us-east-2.amazonaws.com/
...

I've tested it against a v4-signature-only bucket with jclouds debug logs and everything seems to be working great. (when I use the old URI it uses v2 signature and fails).

Default request signer changed to v4 JCLOUDS-1090 - Where I noticed the usage of aws-s3 vs s3 in ContextBuilder

edit: seems like you already suggested that https://groups.google.com/g/dcm4che/c/YxdQYzQxGQc/m/ArGBnckAAgAJ

ngutman commented 3 years ago

Actually, requesting storage verification fails with

Caused by: java.lang.NoClassDefFoundError: com/google/common/hash/HashCode
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear//org.dcm4chee.arc.storage.cloud.CloudStorage.getContentMD5(CloudStorage.java:246)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-stgcmt-5.22.6.jar//org.dcm4chee.arc.stgcmt.impl.StgCmtManagerImpl.compareS3md5Sum(StgCmtManagerImpl.java:602)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-stgcmt-5.22.6.jar//org.dcm4chee.arc.stgcmt.impl.StgCmtManagerImpl.checkLocation(StgCmtManagerImpl.java:518)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-stgcmt-5.22.6.jar//org.dcm4chee.arc.stgcmt.impl.StgCmtManagerImpl.checkLocationsOfInstance(StgCmtManagerImpl.java:471)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-stgcmt-5.22.6.jar//org.dcm4chee.arc.stgcmt.impl.StgCmtManagerImpl.checkLocations(StgCmtManagerImpl.java:406)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-stgcmt-5.22.6.jar//org.dcm4chee.arc.stgcmt.impl.StgCmtManagerImpl.calculateResult(StgCmtManagerImpl.java:166)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-stgcmt-5.22.6.jar//org.dcm4chee.arc.stgcmt.impl.StgCmtManagerImpl$Proxy$_$$_WeldClientProxy.calculateResult(Unknown Source)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-war-5.22.6-secure.war//org.dcm4chee.arc.stgcmt.rs.StgVerRS.storageCommit(StgVerRS.java:151)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-war-5.22.6-secure.war//org.dcm4chee.arc.stgcmt.rs.StgVerRS.studyStorageCommit(StgVerRS.java:114)
        at deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear.dcm4chee-arc-war-5.22.6-secure.war//org.dcm4chee.arc.stgcmt.rs.StgVerRS$Proxy$_$$_WeldClientProxy.studyStorageCommit(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:138)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:543)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:432)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:393)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:395)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:364)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337)
        at org.jboss.resteasy.resteasy-jaxrs@3.12.1.Final//org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:440)
        ... 64 more
Caused by: java.lang.ClassNotFoundException: com.google.common.hash.HashCode from [Module "deployment.dcm4chee-arc-ear-5.22.6-psql-secure.ear" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)

So more changes might be needed (com.google.common.hash dep is missing?)