Repository: oauth2-proxy/oauth2-proxy
Pull request #1699 (2022-06-23 16:17:30)

Fix method deprecated error in lint

## Description

Added `nolint` for the deprecated CertPool.Subjects() method to avoid method deprecated error in lint.

## Motivation and Context

Fix https://github.com/oauth2-proxy/oauth2-proxy/issues/1576

## How Has This Been Tested?

Tested on my local environment.
- WSL Ubuntu 20.04 LTS
- go 1.18
- golangci-lint 1.45.0

```
ubuntu@wsl:oauth2-proxy$ go version
go version go1.18 linux/amd64
ubuntu@wsl:oauth2-proxy$

ubuntu@wsl:oauth2-proxy$ git checkout master
Already on 'master'
Your branch is up to date with 'origin/master'.
ubuntu@wsl:oauth2-proxy$ make lint
GO111MODULE=on golangci-lint run
WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner.  Replaced by revive.
WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner.  Replaced by exportloopref.
pkg/util/util_test.go:86:10: SA1019: certPool.Subjects is deprecated: if s was returned by SystemCertPool, Subjects will not include the system roots. (staticcheck)
        subj := certPool.Subjects()
                ^
make: *** [Makefile:34: lint] Error 1
ubuntu@wsl:oauth2-proxy$

ubuntu@wsl:oauth2-proxy$ git checkout fix/deprecated-lint-issue
Switched to branch 'fix/deprecated-lint-issue'
ubuntu@wsl:oauth2-proxy$ make lint
GO111MODULE=on golangci-lint run
WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner.  Replaced by exportloopref.
WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner.  Replaced by revive.
ubuntu@wsl:oauth2-proxy$
```

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [x] My change requires a change to the documentation or CHANGELOG.
- [x] I have updated the documentation/CHANGELOG accordingly.
- [x] I have created a feature (non-master) branch for my PR.


JoelSpeed: Has `Subjects()` been replaced by some other method? Would it be better to update the code rather than ignore the warning?

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ca7e088a..e5a586db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
 ## Breaking Changes
 
 ## Changes since v7.3.0
+- [#1669](https://github.com/oauth2-proxy/oauth2-proxy/pull/1699) Fix method deprecated error in lint (@t-katsumura)
 
 - [#1709](https://github.com/oauth2-proxy/oauth2-proxy/pull/1709) Show an alert message when basic auth credentials are invalid (@aiciobanu)
 


Test patch:
diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go
index 347f41bb..d5f7860b 100644
--- a/pkg/util/util_test.go
+++ b/pkg/util/util_test.go
@@ -1,8 +1,8 @@
 package util
 
 import (
-	"crypto/x509/pkix"
-	"encoding/asn1"
+	"crypto/x509"
+	"encoding/pem"
 	"io/ioutil"
 	"os"
 	"testing"
@@ -11,45 +11,173 @@ import (
 )
 
 // Test certificate created with an OpenSSL command in the following form:
-// openssl req -x509 -newkey rsa:4096 -keyout key-unused.pem -out cert.pem -nodes -subj "/CN=oauth-proxy test ca"
+// # Create "root1" certification and "cert1" certification signed by "root1" certification.
+// openssl req -x509 -nodes -days 365000 -newkey rsa:4096 -keyout root1.key -out root1.pem -subj "/CN=oauth2-proxy test root1 ca"
+// openssl req -nodes -days 365000 -newkey rsa:4096 -keyout cert1.key -out cert1-req.pem -subj "/CN=oauth2-proxy test cert1 ca"
+// openssl x509 -req -in cert1-req.pem -days 365000 -CA root1.pem -CAkey root1.key -set_serial 01 -out cert1.pem
+// openssl verify -CAfile ./root1.pem cert1.pem
+// # Create "root2" certification and "cert2" certification signed by "root2" certification.
+// openssl req -x509 -nodes -days 365000 -newkey rsa:4096 -keyout root2.key -out root2.pem -subj "/CN=oauth2-proxy test root2 ca"
+// openssl req -nodes -days 365000 -newkey rsa:4096 -keyout cert2.key -out cert2-req.pem -subj "/CN=oauth2-proxy test cert2 ca"
+// openssl x509 -req -in cert2-req.pem -days 365000 -CA root2.pem -CAkey root2.key -set_serial 01 -out cert2.pem
+// openssl verify -CAfile ./root2.pem cert2.pem
+// # Create "root3" certification and "cert3" certification signed by "root3" certification.
+// openssl req -x509 -nodes -days 365000 -newkey rsa:4096 -keyout root3.key -out root3.pem -subj "/CN=oauth2-proxy test root3 ca"
+// openssl req -nodes -days 365000 -newkey rsa:4096 -keyout cert3.key -out cert3-req.pem -subj "/CN=oauth2-proxy test cert3 ca"
+// openssl x509 -req -in cert3-req.pem -days 365000 -CA root3.pem -CAkey root3.key -set_serial 01 -out cert3.pem
+// openssl verify -CAfile ./root3.pem cert3.pem
 
 var (
-	testCA1Subj = "CN=oauth-proxy test ca"
-	testCA1     = `-----BEGIN CERTIFICATE-----
-MIICuTCCAaGgAwIBAgIFAKuKEWowDQYJKoZIhvcNAQELBQAwHjEcMBoGA1UEAxMT
-b2F1dGgtcHJveHkgdGVzdCBjYTAeFw0xNzEwMjQyMDExMzJaFw0xOTEwMjQyMDEx
-MzJaMB4xHDAaBgNVBAMTE29hdXRoLXByb3h5IHRlc3QgY2EwggEiMA0GCSqGSIb3
-DQEBAQUAA4IBDwAwggEKAoIBAQC5/kmgKNiECuxlj27yTWBWOMVvIB0AaRhQrMA7
-3iSCk/SHhaTabUuXUGRwmCAewT/y9oX3rTdfnSPCn7praU/27lRFBgOGFrTzAZH6
-voisF54I3ZxWZgHDJ/ig/KFwd0Y8OATj9/k9uAJSCe6aT7BouJPZVWNGF2dF5BOJ
-EwFsJiN2s8HpF14DhxFOMMtlckdMHGxi3wj3E/hBCfGvGGU4Wezz48vEWWC1ajWM
-qVq2vVWi1bcNft8FjWa5wTGpdlDQJM7yvKYJPwRkEjgIXtF1ra3JM3WTTFZO9Yhd
-QXwO7IWRTdTaypKTNbTDKuWQZsm7xQM9sNcFkukGb3o+uBpLAgMBAAEwDQYJKoZI
-hvcNAQELBQADggEBAHJNrUfHhN7VOUF60pG8sOEkx0ztjbtbYMj2N9Kb0oSya+re
-Kmb2Z4JgyV7XHC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EAATANBgkqhkiG9w0BAQsFAAOCAgEApdjE/eHCFOtBxvyk
+hNtjnXPwkTxesPbK1GwqhdDRA+k8xTFHML/zSS4OwYlxZBGCeBrFmxsN3mOvNnJc
+iNWaqjnKWA+Bec2oTXo7LX+i1YWHh0cJpPrSmMeVoqX1rsiugOzR3FtAawMN+b+Z
+UIC3q0zxZebB074xQxPcMtX7N288VWpFaITLcZftmSQ9w16qAuixVfTYbHQbcE2Q
+hCR2lNlNaGX5N9RaDD+MonB1iSJMFL8G9lhGHLPcjJwjkSHpcGp+yplbMRlsUqww
+ysfSIPMKydlLJUoVfhl1CnZmFE4NidxSF+wV0M3ai9CFGZ34HcXx28Jj8rFjnibN
+AFgjUfC7DvXLb3INJYHi9ZVTXZlliElF5evKhk9NzNXk1gdam+7uFvqPKSYGecX/
+fDcov2LkS95u4Zd692xaiE6UUxT4qcKEoZ5TM0aGjJjx0fDAYqgXes5lA3AYIN0S
+hAEEC1diGFkQivnBjfxKMkauStsV828yTxtqOdlu75sUcW58AUKJ0LZ6bf8gzVSf
+iY7GK6JBDUyme+kio9EutSx5WrTylPzCek9ajNoEUvlmBX8Dz+qG66vFfcff+bo2
+Ixm/I9aL4lNQiCmE5E044L00IX802hE9iSdYqFbUmefKqk9NWK3CPtDoobcFLi6u
+WrW4JMzLaGDtoHxRNNfo8E7fGkQ=
 -----END CERTIFICATE-----
 `
 )
@@ -77,21 +205,34 @@ func TestGetCertPool(t *testing.T) {
 		}
 	}(tempDir)
 
-	certFile1 := makeTestCertFile(t, testCA1, tempDir)
-	certFile2 := makeTestCertFile(t, testCA2, tempDir)
+	certFile1 := makeTestCertFile(t, root1Cert, tempDir)
+	certFile2 := makeTestCertFile(t, root2Cert, tempDir)
 
 	certPool, err := GetCertPool([]string{certFile1.Name(), certFile2.Name()})
 	assert.NoError(t, err)
 
-	subj := certPool.Subjects()
-	got := make([]string, 0)
-	for i := range subj {
-		var subject pkix.RDNSequence
-		_, err := asn1.Unmarshal(subj[i], &subject)
-		assert.NoError(t, err)
-		got = append(got, subject.String())
+	cert1Block, _ := pem.Decode([]byte(cert1Cert))
+	cert1, _ := x509.ParseCertificate(cert1Block.Bytes)
+	assert.Equal(t, cert1.Subject.String(), cert1CertSubj)
+
+	cert2Block, _ := pem.Decode([]byte(cert2Cert))
+	cert2, _ := x509.ParseCertificate(cert2Block.Bytes)
+	assert.Equal(t, cert2.Subject.String(), cert2CertSubj)
+
+	cert3Block, _ := pem.Decode([]byte(cert3Cert))
+	cert3, _ := x509.ParseCertificate(cert3Block.Bytes)
+	assert.Equal(t, cert3.Subject.String(), cert3CertSubj)
+
+	opts := x509.VerifyOptions{
+		Roots: certPool,
 	}
 
-	expectedSubjects := []string{testCA1Subj, testCA2Subj}
-	assert.Equal(t, expectedSubjects, got)
+	// "cert1" and "cert2" should be valid because "root1" and "root2" are in the certPool
+	// "cert3" should not be valid because "root3" is not in the certPool
+	_, err1 := cert1.Verify(opts)
+	assert.NoError(t, err1)
+	_, err2 := cert2.Verify(opts)
+	assert.NoError(t, err2)
+	_, err3 := cert3.Verify(opts)
+	assert.Error(t, err3)
 }