Skip to content

SignatureDoesNotMatch error when putting object with JSON contentType #1616

@thomaschilton-viavi

Description

@thomaschilton-viavi

Version: io.minio:minio:8.5.15

Common logic:
`minioClient = MinioClient.builder().endpoint(minioUrl, minioPort, false).credentials(accessKey, accessSecret).build();

if (!minioClient.bucketExists(BucketExistsArgs.builder().bucket(MINIO_BUCKET).build())) {
minioClient.makeBucket(MakeBucketArgs.builder().bucket(MINIO_BUCKET).build());
}
`

Working code:
InputStream targetStream = new ByteArrayInputStream(content.getBytes()); minioClient.putObject(PutObjectArgs.builder().bucket(MINIO_BUCKET).object(filename).stream(targetStream, content.getBytes().length, -1).build());

Failing code:
InputStream targetStream = new ByteArrayInputStream(content.getBytes()); minioClient.putObject(PutObjectArgs.builder().bucket(MINIO_BUCKET).object(filename).stream(targetStream, content.getBytes().length, -1).contentType("json").build());

Error:
{"@timestamp":"2025-01-15T16:45:05.194Z","log.level": "WARN","message":"Hello Protean unable to store state to minio. Reason: Unable to store file in minio: addition-state", "ecs.version": "1.2.0","process.thread.name":"JettyServerThreadPool-25","log.logger":"com.viavi.hello.protean.HelloProteanApplication","level":"WARN","service.name":"hello-protean","error.type":"com.viavi.hello.protean.minio.MinioRepositoryException","error.message":"Unable to store file in minio: addition-state","error.stack_trace":"com.viavi.hello.protean.minio.MinioRepositoryException: Unable to store file in minio: addition-state\n\tat com.viavi.hello.protean.minio.MinioRepository.storeFileContent(MinioRepository.java:86)\n\tat com.viavi.hello.protean.rest.RestController.postState(RestController.java:282)\n\tat io.javalin.router.Endpoint.handle(Endpoint.kt:52)\n\tat io.javalin.router.ParsedEndpoint.handle(ParsedEndpoint.kt:15)\n\tat io.javalin.http.servlet.DefaultTasks.HTTP$lambda$9$lambda$7$lambda$6(DefaultTasks.kt:52)\n\tat io.javalin.http.servlet.JavalinServlet.handleTask(JavalinServlet.kt:99)\n\tat io.javalin.http.servlet.JavalinServlet.handleSync(JavalinServlet.kt:64)\n\tat io.javalin.http.servlet.JavalinServlet.handle(JavalinServlet.kt:50)\n\tat io.javalin.http.servlet.JavalinServlet.service(JavalinServlet.kt:30)\n\tat jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)\n\tat io.javalin.jetty.JavalinJettyServlet.service(JavalinJettyServlet.kt:52)\n\tat jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)\n\tat org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)\n\tat org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:529)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)\n\tat org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1580)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1381)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)\n\tat org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)\n\tat org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1553)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)\n\tat org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1303)\n\tat org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)\n\tat org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:173)\n\tat io.micrometer.jetty11.TimedHandler.handle(TimedHandler.java:129)\n\tat org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)\n\tat org.eclipse.jetty.server.Server.handle(Server.java:563)\n\tat org.eclipse.jetty.server.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1598)\n\tat org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753)\n\tat org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501)\n\tat org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:287)\n\tat org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)\n\tat org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)\n\tat org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)\n\tat org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:421)\n\tat org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:390)\n\tat org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:277)\n\tat org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:199)\n\tat org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)\n\tat org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)\n\tat java.base/java.lang.Thread.run(Unknown Source)\nCaused by: error occurred\nErrorResponse(code = SignatureDoesNotMatch, message = The request signature we calculated does not match the signature you provided. Check your key and signing method., bucketName = hello-protean, objectName = addition-state, resource = /hello-protean/addition-state, requestId = 181AEB7797E26A2E, hostId = 782d4959-9638-4520-953c-e7689a5f6d0a)\nrequest={method=PUT, url=http://nci-service-minio-default.nci-service-minio-default.svc:9000/hello-protean/addition-state, headers=Content-Type: json\nHost: nci-service-minio-default.nci-service-minio-default.svc:9000\nAccept-Encoding: identity\nUser-Agent: MinIO (Linux; amd64) minio-java/8.5.15\nx-amz-content-sha256: c6f3ac57944a531490cd39902d0f777715fd005efac9a30622d5f5205e7f6894\nx-amz-date: 20250115T164505Z\nAuthorization: ██\n}\nresponse={code=403, headers=Accept-Ranges: bytes\nContent-Length: 425\nContent-Security-Policy: block-all-mixed-content\nContent-Type: application/xml\nServer: MinIO\nStrict-Transport-Security: max-age=31536000; includeSubDomains\nVary: Origin\nVary: Accept-Encoding\nX-Amz-Request-Id: 181AEB7797E26A2E\nX-Content-Type-Options: nosniff\nX-Xss-Protection: 1; mode=block\nDate: Wed, 15 Jan 2025 16:45:05 GMT\n}\n\n\tat io.minio.S3Base$1.onResponse(S3Base.java:775)\n\tat okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)\n\t... 1 more\n"}

Would like to understand why "contentType("json")" causes the SignatureDoesNotMatch error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions