forked from flyteorg/flyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added flag to pass in CAcerts (flyteorg#242)
* Added flag to pass in CAcerts Signed-off-by: Prafulla Mahindrakar <[email protected]> * Incorporated feedback Signed-off-by: Prafulla Mahindrakar <[email protected]> * caCert instead of caCerts Signed-off-by: Prafulla Mahindrakar <[email protected]> * caCert to caCertFilePath Signed-off-by: Prafulla Mahindrakar <[email protected]>
- Loading branch information
1 parent
b24a555
commit 4c7bd49
Showing
9 changed files
with
131 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package admin | ||
|
||
import ( | ||
"fmt" | ||
"io/ioutil" | ||
|
||
"crypto/x509" | ||
) | ||
|
||
// readCACerts from the passed in file at certLoc and return certpool. | ||
func readCACerts(certLoc string) (*x509.CertPool, error) { | ||
rootPEM, err := ioutil.ReadFile(certLoc) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to read from %v file due to %v", certLoc, err) | ||
} | ||
rootCertPool := x509.NewCertPool() | ||
ok := rootCertPool.AppendCertsFromPEM(rootPEM) | ||
if !ok { | ||
return nil, fmt.Errorf("failed to parse root certificate file %v due to %v", certLoc, err) | ||
} | ||
return rootCertPool, err | ||
} |
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,28 @@ | ||
package admin | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestReadCACerts(t *testing.T) { | ||
|
||
t.Run("legal", func(t *testing.T) { | ||
x509Pool, err := readCACerts("testdata/root.pem") | ||
assert.NoError(t, err) | ||
assert.NotNil(t, x509Pool) | ||
}) | ||
|
||
t.Run("illegal", func(t *testing.T) { | ||
x509Pool, err := readCACerts("testdata/invalid-root.pem") | ||
assert.NotNil(t, err) | ||
assert.Nil(t, x509Pool) | ||
}) | ||
|
||
t.Run("non-existent", func(t *testing.T) { | ||
x509Pool, err := readCACerts("testdata/non-existent.pem") | ||
assert.NotNil(t, err) | ||
assert.Nil(t, x509Pool) | ||
}) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
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,24 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIEBDCCAuygAwIBAgIDAjppMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT | ||
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i | ||
YWwgQ0EwHhcNMTMwNDA1MTUxNTU1WhcNMTUwNDA0MTUxNTU1WjBJMQswCQYDVQQG | ||
EwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzElMCMGA1UEAxMcR29vZ2xlIEludGVy | ||
bmV0IEF1dGhvcml0eSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB | ||
AJwqBH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