|
| 1 | +# Testing tough FIPS feature |
| 2 | + |
| 3 | +The following are steps to take to test FIPS support with `tough` and `tuftool`. Steps will walk |
| 4 | +through creating a TUF repo, hosting the repo via Docker containers running nginx, and testing |
| 5 | +`tuftool download` against servers using FIPS and non-FIPS ciphers. Creation of the TUF repo |
| 6 | +relies on AWS KMS for signing. |
| 7 | + |
| 8 | +## Install tuftool |
| 9 | + |
| 10 | +```sh |
| 11 | +# From latest release |
| 12 | +$ cargo install --force tuftool --all-features |
| 13 | +``` |
| 14 | + |
| 15 | +```sh |
| 16 | +# From local changes |
| 17 | +$ cargo install --path ../../tuftool --all-features |
| 18 | +``` |
| 19 | + |
| 20 | +## Create TUF repo |
| 21 | + |
| 22 | +```sh |
| 23 | +$ mkdir -p test-tuf-repo |
| 24 | +$ ./scripts/create-tuf-repo.sh |
| 25 | +``` |
| 26 | + |
| 27 | +This will create the repo under the "test-tuf-repo" directory. |
| 28 | + |
| 29 | +## Create keys |
| 30 | + |
| 31 | +```sh |
| 32 | +$ ./scripts/create-server-keys.sh |
| 33 | +``` |
| 34 | + |
| 35 | +Trust the generated server Certificate Authority on your host: |
| 36 | + |
| 37 | +```sh |
| 38 | +sudo trust anchor --store ./test-keys/ca.crt |
| 39 | +``` |
| 40 | + |
| 41 | +## Build the tough-fips-testing container |
| 42 | + |
| 43 | +```sh |
| 44 | +docker build . -t tough-fips-testing:latest |
| 45 | +``` |
| 46 | + |
| 47 | +## Run the server with FIPS |
| 48 | + |
| 49 | +```sh |
| 50 | +docker run --rm -it -p 8080:443 \ |
| 51 | + -v ./configs/nginx-fips.conf:/etc/nginx/nginx.conf \ |
| 52 | + -v ./test-tuf-repo/out/metadata:/usr/share/nginx/html/metadata \ |
| 53 | + -v ./test-tuf-repo/out/targets:/usr/share/nginx/html/targets \ |
| 54 | + --mount type=bind,src=./test-keys/server.crt,dst=/etc/pki/tls/certs/domain.crt \ |
| 55 | + --mount type=bind,src=./test-keys/server.key,dst=/etc/pki/tls/private/domain.key \ |
| 56 | + tough-fips-testing:latest |
| 57 | +``` |
| 58 | + |
| 59 | +Test repo download: |
| 60 | + |
| 61 | +```sh |
| 62 | +tuftool download -r ./test-tuf-repo/1.root.json \ |
| 63 | + --targets-url https://localhost:8080/targets \ |
| 64 | + --metadata-url https://localhost:8080/metadata \ |
| 65 | + test-fips-tough |
| 66 | +``` |
| 67 | + |
| 68 | +Should succeed with: |
| 69 | + |
| 70 | +``` |
| 71 | +Downloading targets to "test-fips-tough" |
| 72 | +``` |
| 73 | + |
| 74 | +Clean up the downloaded repo: |
| 75 | + |
| 76 | +```sh |
| 77 | +rm -rf test-fips-tough/ |
| 78 | +``` |
| 79 | + |
| 80 | +**Stop the Docker container.** |
| 81 | + |
| 82 | +## Run the server with non-FIPS ciphers |
| 83 | + |
| 84 | +```sh |
| 85 | +docker run --rm -it -p 8080:443 \ |
| 86 | + -v ./configs/nginx.conf:/etc/nginx/nginx.conf \ |
| 87 | + -v ./test-tuf-repo/out/metadata:/usr/share/nginx/html/metadata \ |
| 88 | + -v ./test-tuf-repo/out/targets:/usr/share/nginx/html/targets \ |
| 89 | + --mount type=bind,src=./test-keys/server.crt,dst=/etc/pki/tls/certs/domain.crt \ |
| 90 | + --mount type=bind,src=./test-keys/server.key,dst=/etc/pki/tls/private/domain.key \ |
| 91 | + tough-fips-testing:latest |
| 92 | +``` |
| 93 | + |
| 94 | +Test repo download: |
| 95 | + |
| 96 | +```sh |
| 97 | +tuftool download -r ./test-tuf-repo/1.root.json \ |
| 98 | + --targets-url https://localhost:8080/targets \ |
| 99 | + --metadata-url https://localhost:8080/metadata \ |
| 100 | + test-fips-tough |
| 101 | +``` |
| 102 | + |
| 103 | +Expect failure: |
| 104 | + |
| 105 | +``` |
| 106 | +Failed to load repository: Failed to fetch https://localhost:8080/metadata/2.root.json: Transport 'other' error fetching 'https://localhost:8080/metadata/2.root.json': error sending request for url (https://localhost:8080/metadata/2.root.json) |
| 107 | +``` |
| 108 | + |
| 109 | +# Clean up |
| 110 | + |
| 111 | +``` |
| 112 | +rm -rf test-tuf-repo/ |
| 113 | +rm -rf test-keys/ |
| 114 | +rm -rf test-fips-tough/ |
| 115 | +``` |
0 commit comments