Skip to content

Commit b5750e9

Browse files
committed
Document SSL certificate usage
S3Mock includes a self-signed SSL certificate which must be accepted by any client accessing S3Mock. Fixes #281
1 parent ccb9185 commit b5750e9

File tree

1 file changed

+71
-5
lines changed

1 file changed

+71
-5
lines changed

README.md

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
* [Usage of AWS S3 SDKs](#usage-of-aws-s3-sdks)
1717
* [Path-style vs Domain-style access](#path-style-vs-domain-style-access)
1818
* [Presigned URLs](#presigned-urls)
19+
* [Self-signed SSL certificate](#self-signed-ssl-certificate)
1920
* [Usage of AWS CLI](#usage-of-aws-cli)
20-
* [Usage of plain HTTP](#usage-of-plain-http)
21+
* [Usage of plain HTTP / HTTPS with cURL](#usage-of-plain-http--https-with-curl)
2122
* [S3Mock configuration options](#s3mock-configuration-options)
2223
* [S3Mock Docker](#s3mock-docker)
2324
* [Start using the command-line](#start-using-the-command-line)
@@ -26,6 +27,7 @@
2627
* [Start using Docker compose](#start-using-docker-compose)
2728
* [Simple example](#simple-example)
2829
* [Expanded example](#expanded-example)
30+
* [Start using self-signed SSL certificate](#start-using-self-signed-ssl-certificate)
2931
* [S3Mock Java](#s3mock-java)
3032
* [Start using the JUnit4 Rule](#start-using-the-junit4-rule)
3133
* [Start using the JUnit5 Extension](#start-using-the-junit5-extension)
@@ -193,9 +195,16 @@ For instance, S3Mock does not verify the HTTP verb that the presigned uri was cr
193195

194196
S3 SDKs can be used to create presigned URLs pointing to S3Mock if they're configured for path-style access. See the "Usage of..." section above for links to examples on how to use the SDK with presigned URLs.
195197

198+
#### Self-signed SSL certificate
199+
200+
S3Mock supports connections via HTTP and HTTPS. It includes a self-signed SSL certificate which is rejected by most HTTP clients by default.
201+
To use HTTPS, the self-signed certificate must be accepted by the client. This can be done by setting the `--no-verify-ssl` option in the AWS CLI or by using the `--insecure` option in cURL, see below.
202+
203+
Java and Kotlin SDKs can be configured to trust any SSL certificate, see links to `S3Client` creation above.
204+
196205
### Usage of AWS CLI
197206

198-
S3Mock can be used with the AWS CLI. Setting the `--endpoint-url` enables path-style access.
207+
S3Mock can be used with the AWS CLI. Setting the `--endpoint-url` enables path-style access, `--no-verify-ssl` is needed for HTTPS access.
199208

200209
Examples:
201210

@@ -214,9 +223,14 @@ Get object
214223
aws s3api get-object --bucket my-bucket --key my-file --endpoint-url=http://localhost:9090 my-file-output
215224
```
216225

217-
### Usage of plain HTTP
226+
Get object using HTTPS
227+
```shell
228+
aws s3api get-object --bucket my-bucket --key my-file --no-verify-ssl --endpoint-url=https://localhost:9191 my-file-output
229+
```
230+
231+
### Usage of plain HTTP / HTTPS with cURL
218232

219-
As long as the requests work with the S3 API, they will work with S3Mock as well.
233+
As long as the requests work with the S3 API, they will work with S3Mock as well. Use `--insecure` to ignore SSL errors.
220234

221235
Examples:
222236

@@ -232,7 +246,12 @@ curl --request PUT --upload-file ./my-file http://localhost:9090/my-test-bucket/
232246

233247
Get object
234248
```shell
235-
curl --request GET http://localhost:9090/my-test-bucket/my-file
249+
curl --request GET http://localhost:9090/my-test-bucket/my-file -O
250+
```
251+
252+
Get object using HTTPS
253+
```shell
254+
curl --insecure --request GET https://localhost:9191/my-test-bucket/my-file -O
236255
```
237256

238257
### S3Mock configuration options
@@ -388,6 +407,53 @@ $ ls locals3root/my-test-bucket
388407
bucketMetadata.json
389408
```
390409

410+
#### Start using self-signed SSL certificate
411+
412+
S3Mock includes a self-signed SSL certificate:
413+
414+
```shell
415+
$ curl -vvv --insecure --request GET https://localhost:9191/my-test-bucket/my-file -O
416+
[...]
417+
* Server certificate:
418+
* subject: C=DE; ST=Hamburg; L=Hamburg; O=S3Mock; OU=S3Mock; CN=Adobe S3Mock
419+
* start date: Jul 25 12:28:53 2022 GMT
420+
* expire date: Nov 25 12:28:53 3021 GMT
421+
* issuer: C=DE; ST=Hamburg; L=Hamburg; O=S3Mock; OU=S3Mock; CN=Adobe S3Mock
422+
* SSL certificate verify result: self signed certificate (18), continuing anyway.
423+
[...]
424+
```
425+
426+
To use a custom self-signed SSL certificate, derive your own Docker container from the S3Mock container:
427+
428+
```dockerfile
429+
FROM adobe/s3mock:4.2.0
430+
431+
ENV server.ssl.key-store=/opt/customcert.jks
432+
ENV server.ssl.key-store-password=password
433+
ENV server.ssl.key-alias=selfsigned
434+
435+
RUN keytool -genkey -keyalg RSA -alias selfsigned \
436+
-validity 360 \
437+
-keystore /opt/customcert.jks \
438+
-dname "cn=Test, ou=Test, o=Docker, l=NY, st=NY, c=US" \
439+
-storepass password -keysize 2048 \
440+
-ext "san=dns:localhost"
441+
```
442+
443+
```shell
444+
$ curl -vvv --insecure --request GET https://localhost:9191/my-test-bucket/my-file -O
445+
[...]
446+
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
447+
* ALPN: server did not agree on a protocol. Uses default.
448+
* Server certificate:
449+
* subject: C=US; ST=NY; L=NY; O=Docker; OU=Test; CN=Test
450+
* start date: May 9 14:33:40 2025 GMT
451+
* expire date: May 4 14:33:40 2026 GMT
452+
* issuer: C=US; ST=NY; L=NY; O=Docker; OU=Test; CN=Test
453+
* SSL certificate verify result: self signed certificate (18), continuing anyway.
454+
[...]
455+
```
456+
391457
### S3Mock Java
392458

393459
`S3Mock` Java libraries are released and published to the Sonatype Maven Repository and subsequently published to

0 commit comments

Comments
 (0)