updating proxy cert validation

This commit is contained in:
Dhwani Shah 2023-10-21 05:38:11 -07:00
Родитель 82d2ddcdcc
Коммит be6f8215e5
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -48,8 +48,8 @@ func ValidateProxyURL(proxyURL string) error {
func ValidateCertFormatIsBase64(certContent string) error {
certContent = strings.Replace(certContent, "-----BEGIN CERTIFICATE-----\\n", "", -1)
certContent = strings.Replace(certContent, "\\n-----END CERTIFICATE-----", "", -1)
certContent = strings.Replace(certContent, "-----BEGIN CERTIFICATE-----", "", -1)
certContent = strings.Replace(certContent, "-----END CERTIFICATE-----", "", -1)
_, err := base64.StdEncoding.DecodeString(certContent)
if err != nil {
return errors.Wrapf(errors.InvalidInput, err.Error())

Просмотреть файл

@ -27,7 +27,7 @@ func Test_ValidateProxyURL(t *testing.T) {
}
func Test_ValidateCertFormatIsBase64(t *testing.T) {
certContent := "-----BEGIN CERTIFICATE-----\\nMIIDETCCAfkCFAjEhG/xypxPKN1URzLmLISCPuTVMA0GCSqGSIb3DQEBCwUAMEUx\\n-----END CERTIFICATE-----"
certContent := "-----BEGIN CERTIFICATE-----MIIDETCCAfkCFAjEhG/xypxPKN1URzLmLISCPuTVMA0GCSqGSIb3DQEBCwUAMEUx-----END CERTIFICATE-----"
err := ValidateCertFormatIsBase64(certContent)
if err != nil {
t.Fatalf("Test_ValidateCertFormat test case failed - Certificate content is not base64 encoded")