Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mTLS #440

Merged
merged 7 commits into from
May 31, 2023
Merged

mTLS #440

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fastly/custom_tls_activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func (c *Client) CreateTLSActivation(i *CreateTLSActivationInput) (*TLSActivatio
if err != nil {
return nil, err
}
defer r.Body.Close()

var a TLSActivation
if err := jsonapi.UnmarshalPayload(r.Body, &a); err != nil {
Expand All @@ -175,6 +176,8 @@ type UpdateTLSActivationInput struct {
Certificate *CustomTLSCertificate `jsonapi:"relation,tls_certificate"` // Only ID of CustomTLSCertificate needs to be set.
// ID is an aphanumeric string identifying a TLS activation.
ID string `jsonapi:"primary,tls_activation"`
// MutualAuthentication is an alphanumeric string identifying a mutual authentication.
MutualAuthentication *TLSMutualAuthentication `jsonapi:"relation,mutual_authentication"` // Only ID of TLSMutualAuthentication needs to be set.
}

// UpdateTLSActivation updates the specified resource.
Expand Down
4 changes: 4 additions & 0 deletions fastly/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ var ErrMissingBackend = NewFieldError("Backend")
// requires a "CertBlob" key, but one was not set.
var ErrMissingCertBlob = NewFieldError("CertBlob")

// ErrMissingCertBundle is an error that is returned when an input struct
// requires a "CertBundle" key, but one was not set.
var ErrMissingCertBundle = NewFieldError("CertBundle")

// ErrMissingContent is an error that is returned when an input struct
// requires a "Content" key, but one was not set.
var ErrMissingContent = NewFieldError("Content")
Expand Down
49 changes: 49 additions & 0 deletions fastly/fixtures/mutual_authentication/create-cert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
version: 1
interactions:
- request:
body: |
{"data":{"type":"tls_certificate","attributes":{"cert_blob":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMxMTE0ODI2WhcNMjMwODI5MTE0ODI2WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBALcgLS9FIWYSRw7MLpEV/4nvmlDA95jlXZnejar9\nVbKXxWzEljZZVtp+CniP1ef6OBBwIph9bX9ig+96cMWR1GMlu7kddIisuSFhndPv\nQxCNW6r5Vlh0q9inuizXBdh48Ql4/xWWWHPfGBYFUzHhDaw1qlyH28E1RRp6LsfE\nVh0r5K+NuuL3ZAsXyRM1uzt62mczraVbKLHGjag/5vsgC48Yak9hLC4jUu6cPE9L\nsVX5xAbu21U7TuZslI4nerSsHAMu9463MJh4eTyKhQQiJABql+TiO7+jkDWu/InC\nOvmF3dasTq6HDEKj7Io2m6uTlWCZ0xSdyceWl6h+7OHBbTcCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFL3co7IUnrTsHPO6Xhq5e9IGUkfCMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCyKG37ZQbVFC2ATfcgYcJm9sfF\nraLcm0Ft206ZvWZ8++48G4pE6vSWcnMioMv6vffD/wRSo606Yur1GZ2TsrBok9VE\n7yNXQa+zT/pdvK7XheuCQOfX1PHS6Xe1VK657GMHTGAZZZsssTbb1PdbSkOoLR/w\nqdFf1qbwMUb5Nak4xlOlcInbUVljpSKxt0FcZJjWglINaMyVMG/B1IFFtQX3S8+c\nca7fXIvl9Vw1RO/7/HS9veQ9x1IZmuYW2VelwAkhn33qGdKcRBOAm8UOAdKQH4gT\nMrD7Hc0fqiqvwFDmBQIz5beWeUfxZWtBg+ivFmj739EfdmvkjuqK36kj3LtY\n-----END CERTIFICATE-----","name":"My custom certificate"}}}
form: {}
headers:
Accept:
- application/vnd.api+json
Content-Type:
- application/vnd.api+json
User-Agent:
- FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5)
url: https://api.fastly.com/tls/certificates
method: POST
response:
body: '{"data":{"id":"vOJL3187my51i5ITgcr7H2","type":"tls_certificate","attributes":{"created_at":"2023-05-31T11:48:27.000Z","issued_to":"example.com","issuer":"example.com","name":"My
custom certificate","not_after":"2023-08-29T11:48:26.000Z","not_before":"2023-05-31T11:48:26.000Z","replace":false,"serial_number":"5577006791947779410","signature_algorithm":"SHA256-RSA","updated_at":"2023-05-31T11:48:27.000Z"},"relationships":{"tls_domains":{"data":[{"id":"example.com","type":"tls_domain"}]}}}}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- private
Content-Length:
- "492"
Content-Type:
- application/vnd.api+json
Date:
- Wed, 31 May 2023 11:48:28 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Content-Type-Options:
- nosniff
X-Served-By:
- cache-control-cp-aws-us-east-2-prod-4-CONTROL-AWS-UE2, cache-lhr7383-LHR
X-Timer:
- S1685533707.484825,VS0,VE1050
status: 201 Created
code: 201
duration: ""
49 changes: 49 additions & 0 deletions fastly/fixtures/mutual_authentication/create-key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
version: 1
interactions:
- request:
body: |
{"data":{"type":"","attributes":{"key":"-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgk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yAGzI5me0yLWKwro3jtiMy7+PQlyPIKpnD3\nSTlazisi9QKBgQC2lsLM9OnxA9ZANID+qECEOJ7qZOCwhl/rt0Gjc40FSKnl6agL\nvbwjZROgMuIVlNpVp2zNuXFvIv/6KzquT1VVgrMZjhRdBaVadvN2kRXuVKRAuHWy\nRRG6uw5WC5fhNS2xdUQX4juaMi6cjLFmFeX+/M/34UVJrVlklrUYe8Iv2QKBgA6E\nqoK2nZGMkxS5vfb39WtyXuAg0iHFZrGWBMk+9an+UqCUGtJnNSGQtBl81Plqutkl\nWNPZ+8M4eZXL+IFeq8QolkXmnCHro9VOhWOmRIklHbtZIMgbHxxiRJrgnUt4aM32\n3Q8JRjEGXQKKaAlMOnAjL41B8vbzBGAu/8T4UFOtAoGAb3+vWxbDIGk6mMJmUp3c\nGEkZVvZEqTHI2seJ/lT+D+UOnuFWwzACkk1KjRmgkkrVXgwO8qrEfby06OEtxmMK\ntbVtOCK/mDFyddLxEP2i355ZA4606oNMSkpyur1UO740m1Qvy2XzzDk+I0ETQBku\nRTyVXNLXU0ELgTxPQF4Cx/0=\n-----END PRIVATE KEY-----","name":"My private key"}}}
form: {}
headers:
Accept:
- application/vnd.api+json
Content-Type:
- application/vnd.api+json
User-Agent:
- FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5)
url: https://api.fastly.com/tls/private_keys
method: POST
response:
body: '{"data":{"id":"0LYME3yUMZpE0lKca6dGr2","type":"tls_private_key","attributes":{"key_length":2048,"key_type":"RSA","name":"My
private key","created_at":null,"replace":false,"public_key_sha1":"29e60e9152953916b47b48e5bc174930c304ddc3"}}}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- private
Content-Length:
- "234"
Content-Type:
- application/vnd.api+json
Date:
- Wed, 31 May 2023 11:48:27 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Content-Type-Options:
- nosniff
X-Served-By:
- cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7383-LHR
X-Timer:
- S1685533707.959293,VS0,VE488
status: 201 Created
code: 201
duration: ""
49 changes: 49 additions & 0 deletions fastly/fixtures/mutual_authentication/create-tma.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
version: 1
interactions:
- request:
body: |
{"data":{"type":"mutual_authentication","attributes":{"cert_bundle":"-----BEGIN CERTIFICATE-----\nMIIDWTCCAkGgAwIBAgIITWWCIQf8/VIwDQYJKoZIhvcNAQELBQAwNDEUMBIGA1UE\nAxMLZXhhbXBsZS5jb20xHDAaBgNVBAUTEzU1NzcwMDY3OTE5NDc3Nzk0MTAwHhcN\nMjMwNTMxMTE0ODI2WhcNMjMwODI5MTE0ODI2WjA0MRQwEgYDVQQDEwtleGFtcGxl\nLmNvbTEcMBoGA1UEBRMTNTU3NzAwNjc5MTk0Nzc3OTQxMDCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBALcgLS9FIWYSRw7MLpEV/4nvmlDA95jlXZnejar9\nVbKXxWzEljZZVtp+CniP1ef6OBBwIph9bX9ig+96cMWR1GMlu7kddIisuSFhndPv\nQxCNW6r5Vlh0q9inuizXBdh48Ql4/xWWWHPfGBYFUzHhDaw1qlyH28E1RRp6LsfE\nVh0r5K+NuuL3ZAsXyRM1uzt62mczraVbKLHGjag/5vsgC48Yak9hLC4jUu6cPE9L\nsVX5xAbu21U7TuZslI4nerSsHAMu9463MJh4eTyKhQQiJABql+TiO7+jkDWu/InC\nOvmF3dasTq6HDEKj7Io2m6uTlWCZ0xSdyceWl6h+7OHBbTcCAwEAAaNvMG0wDgYD\nVR0PAQH/BAQDAgIEMBMGA1UdJQQMMAoGCCsGAQUFBwMBMA8GA1UdEwEB/wQFMAMB\nAf8wHQYDVR0OBBYEFL3co7IUnrTsHPO6Xhq5e9IGUkfCMBYGA1UdEQQPMA2CC2V4\nYW1wbGUuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQCyKG37ZQbVFC2ATfcgYcJm9sfF\nraLcm0Ft206ZvWZ8++48G4pE6vSWcnMioMv6vffD/wRSo606Yur1GZ2TsrBok9VE\n7yNXQa+zT/pdvK7XheuCQOfX1PHS6Xe1VK657GMHTGAZZZsssTbb1PdbSkOoLR/w\nqdFf1qbwMUb5Nak4xlOlcInbUVljpSKxt0FcZJjWglINaMyVMG/B1IFFtQX3S8+c\nca7fXIvl9Vw1RO/7/HS9veQ9x1IZmuYW2VelwAkhn33qGdKcRBOAm8UOAdKQH4gT\nMrD7Hc0fqiqvwFDmBQIz5beWeUfxZWtBg+ivFmj739EfdmvkjuqK36kj3LtY\n-----END CERTIFICATE-----","name":"My mutual authentication"}}}
form: {}
headers:
Accept:
- application/vnd.api+json
Content-Type:
- application/vnd.api+json
User-Agent:
- FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5)
url: https://api.fastly.com/tls/mutual_authentications
method: POST
response:
body: '{"data":{"id":"4tFjGkmDCvPr7f4I9RlDq5","type":"mutual_authentication","attributes":{"created_at":"2023-05-31T11:48:28.000Z","enforced":true,"name":"My
mutual authentication","updated_at":"2023-05-31T11:48:28.000Z"},"relationships":{"tls_activations":{"data":[]}}}}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- private
Content-Length:
- "264"
Content-Type:
- application/vnd.api+json
Date:
- Wed, 31 May 2023 11:48:28 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Content-Type-Options:
- nosniff
X-Served-By:
- cache-control-cp-aws-us-east-2-prod-4-CONTROL-AWS-UE2, cache-lhr7383-LHR
X-Timer:
- S1685533709.558327,VS0,VE205
status: 201 Created
code: 201
duration: ""
39 changes: 39 additions & 0 deletions fastly/fixtures/mutual_authentication/delete-cert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5)
url: https://api.fastly.com/tls/certificates/vOJL3187my51i5ITgcr7H2
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- private
Date:
- Wed, 31 May 2023 11:48:30 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Content-Type-Options:
- nosniff
X-Served-By:
- cache-control-cp-aws-us-east-2-prod-2-CONTROL-AWS-UE2, cache-lhr7383-LHR
X-Timer:
- S1685533710.169246,VS0,VE309
status: 204 No Content
code: 204
duration: ""
39 changes: 39 additions & 0 deletions fastly/fixtures/mutual_authentication/delete-key.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5)
url: https://api.fastly.com/tls/private_keys/0LYME3yUMZpE0lKca6dGr2
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- private
Date:
- Wed, 31 May 2023 11:48:30 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Content-Type-Options:
- nosniff
X-Served-By:
- cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7383-LHR
X-Timer:
- S1685533710.499519,VS0,VE181
status: 204 No Content
code: 204
duration: ""
39 changes: 39 additions & 0 deletions fastly/fixtures/mutual_authentication/delete-tma.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5)
url: https://api.fastly.com/tls/mutual_authentications/4tFjGkmDCvPr7f4I9RlDq5
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Cache-Control:
- private
Date:
- Wed, 31 May 2023 11:48:30 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Content-Type-Options:
- nosniff
X-Served-By:
- cache-control-cp-aws-us-east-2-prod-2-CONTROL-AWS-UE2, cache-lhr7383-LHR
X-Timer:
- S1685533710.907186,VS0,VE239
status: 204 No Content
code: 204
duration: ""
46 changes: 46 additions & 0 deletions fastly/fixtures/mutual_authentication/get.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5)
url: https://api.fastly.com/tls/mutual_authentications/4tFjGkmDCvPr7f4I9RlDq5
method: GET
response:
body: '{"data":{"id":"4tFjGkmDCvPr7f4I9RlDq5","type":"mutual_authentication","attributes":{"created_at":"2023-05-31T11:48:28.000Z","enforced":true,"name":"My
mutual authentication","updated_at":"2023-05-31T11:48:28.000Z"},"relationships":{"tls_activations":{"data":[]}}}}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- private
Content-Length:
- "264"
Content-Type:
- application/vnd.api+json
Date:
- Wed, 31 May 2023 11:48:29 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Content-Type-Options:
- nosniff
X-Served-By:
- cache-control-cp-aws-us-east-2-prod-7-CONTROL-AWS-UE2, cache-lhr7383-LHR
X-Timer:
- S1685533709.110117,VS0,VE314
status: 200 OK
code: 200
duration: ""
48 changes: 48 additions & 0 deletions fastly/fixtures/mutual_authentication/list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
Accept:
- application/vnd.api+json
User-Agent:
- FastlyGo/8.3.0 (+github.com/fastly/go-fastly; go1.18.5)
url: https://api.fastly.com/tls/mutual_authentications
method: GET
response:
body: '{"data":[{"id":"4tFjGkmDCvPr7f4I9RlDq5","type":"mutual_authentication","attributes":{"created_at":"2023-05-31T11:48:28.000Z","enforced":true,"name":"My
mutual authentication","updated_at":"2023-05-31T11:48:28.000Z"},"relationships":{"tls_activations":{"data":[]}}}],"links":{"self":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100","first":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100","prev":null,"next":null,"last":"https://api.fastly.com/tls/mutual_authentications?page%5Bnumber%5D=1\u0026page%5Bsize%5D=100"},"meta":{"per_page":100,"current_page":1,"record_count":1,"total_pages":1}}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- private
Content-Length:
- "681"
Content-Type:
- application/vnd.api+json
Date:
- Wed, 31 May 2023 11:48:29 GMT
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Content-Type-Options:
- nosniff
X-Served-By:
- cache-control-cp-aws-us-east-2-prod-6-CONTROL-AWS-UE2, cache-lhr7383-LHR
X-Timer:
- S1685533709.786855,VS0,VE299
status: 200 OK
code: 200
duration: ""
Loading