Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rgw: use insecure TLS for bucket health check
We have seen cases where the signed certificate used for the RGW does not contain the internal DNS endpoint, resulting in the health check to fail since the certificate is not valid for this domain. People consuming the gateways by external clients and for specific domains do not necessarily have the internal DNS configured in the certificate. So let's be a bit more flexible and simply ensure a connectivity check and bypass the certificate validation. Also, this is fixing the tls code in newS3Agent and adds unit tests. Closes: #8663 Signed-off-by: Sébastien Han <seb@redhat.com>
- Loading branch information
Showing
6 changed files
with
107 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright 2021 The Rook Authors. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package object | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNewS3Agent(t *testing.T) { | ||
accessKey := "accessKey" | ||
secretKey := "secretKey" | ||
endpoint := "endpoint" | ||
region := "region" | ||
|
||
t.Run("test without tls/debug", func(t *testing.T) { | ||
debug := false | ||
insecure := false | ||
s3Agent, err := newS3Agent(accessKey, secretKey, endpoint, region, debug, nil, insecure) | ||
assert.NoError(t, err) | ||
assert.NotEqual(t, aws.LogDebug, s3Agent.Client.Config.LogLevel) | ||
assert.Equal(t, nil, s3Agent.Client.Config.HTTPClient.Transport) | ||
}) | ||
t.Run("test with debug without tls", func(t *testing.T) { | ||
debug := true | ||
logLevel := aws.LogDebug | ||
insecure := false | ||
s3Agent, err := newS3Agent(accessKey, secretKey, endpoint, region, debug, nil, insecure) | ||
assert.NoError(t, err) | ||
assert.Equal(t, &logLevel, s3Agent.Client.Config.LogLevel) | ||
assert.Nil(t, s3Agent.Client.Config.HTTPClient.Transport) | ||
}) | ||
t.Run("test without tls client cert but insecure tls", func(t *testing.T) { | ||
debug := true | ||
insecure := true | ||
s3Agent, err := newS3Agent(accessKey, secretKey, endpoint, region, debug, nil, insecure) | ||
assert.NoError(t, err) | ||
assert.Nil(t, s3Agent.Client.Config.HTTPClient.Transport.(*http.Transport).TLSClientConfig.RootCAs) | ||
assert.True(t, s3Agent.Client.Config.HTTPClient.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify) | ||
}) | ||
t.Run("test with secure tls client cert", func(t *testing.T) { | ||
debug := true | ||
insecure := false | ||
tlsCert := []byte("tlsCert") | ||
s3Agent, err := newS3Agent(accessKey, secretKey, endpoint, region, debug, tlsCert, insecure) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, s3Agent.Client.Config.HTTPClient.Transport.(*http.Transport).TLSClientConfig.RootCAs) | ||
}) | ||
t.Run("test with insesure tls client cert", func(t *testing.T) { | ||
debug := true | ||
insecure := true | ||
tlsCert := []byte("tlsCert") | ||
s3Agent, err := newS3Agent(accessKey, secretKey, endpoint, region, debug, tlsCert, insecure) | ||
assert.NoError(t, err) | ||
assert.NotNil(t, s3Agent.Client.Config.HTTPClient.Transport) | ||
assert.True(t, s3Agent.Client.Config.HTTPClient.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters