@@ -21,6 +21,16 @@ if (!regionUtil.getEndpointSuffix) {
21
21
throw new Error ( 'This version of AWS SDK for JS does not have the \'getEndpointSuffix\' function!' ) ;
22
22
}
23
23
24
+ export interface S3ClientOptions {
25
+ /**
26
+ * If APIs are used that require MD5 checksums.
27
+ *
28
+ * Some S3 APIs in SDKv2 have a bug that always requires them to use a MD5 checksum.
29
+ * These APIs are not going to be supported in a FIPS environment.
30
+ */
31
+ needsMd5Checksums ?: boolean ;
32
+ }
33
+
24
34
export interface ISDK {
25
35
/**
26
36
* The region this SDK has been instantiated for
@@ -56,7 +66,7 @@ export interface ISDK {
56
66
ec2 ( ) : AWS . EC2 ;
57
67
iam ( ) : AWS . IAM ;
58
68
ssm ( ) : AWS . SSM ;
59
- s3 ( ) : AWS . S3 ;
69
+ s3 ( options ?: S3ClientOptions ) : AWS . S3 ;
60
70
route53 ( ) : AWS . Route53 ;
61
71
ecr ( ) : AWS . ECR ;
62
72
ecs ( ) : AWS . ECS ;
@@ -173,19 +183,24 @@ export class SDK implements ISDK {
173
183
return this . wrapServiceErrorHandling ( new AWS . SSM ( this . config ) ) ;
174
184
}
175
185
176
- public s3 ( ) : AWS . S3 {
177
- return this . wrapServiceErrorHandling ( new AWS . S3 ( {
186
+ public s3 ( {
187
+ needsMd5Checksums : apiRequiresMd5Checksum = false ,
188
+ } : S3ClientOptions = { } ) : AWS . S3 {
189
+ const config = { ...this . config } ;
190
+
191
+ if ( ! apiRequiresMd5Checksum ) {
178
192
// In FIPS enabled environments, the MD5 algorithm is not available for use in crypto module.
179
193
// However by default the S3 client is using an MD5 checksum for content integrity checking.
180
194
// While this usage is technically allowed in FIPS (MD5 is only prohibited for cryptographic use),
181
195
// in practice it is just easier to use an allowed checksum mechanism.
182
196
// We are disabling the S3 content checksums, and are re-enabling the regular SigV4 body signing.
183
197
// SigV4 uses SHA256 for their content checksum. This configuration matches the default behavior
184
- // of the AWS SDKv3 and is a safe choice for all users.
185
- s3DisableBodySigning : false ,
186
- computeChecksums : false ,
187
- ...this . config ,
188
- } ) ) ;
198
+ // of the AWS SDKv3 and is a safe choice for all users, except in the above APIs.
199
+ config . s3DisableBodySigning = false ;
200
+ config . computeChecksums = false ;
201
+ }
202
+
203
+ return this . wrapServiceErrorHandling ( new AWS . S3 ( config ) ) ;
189
204
}
190
205
191
206
public route53 ( ) : AWS . Route53 {
0 commit comments