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

[POC] Test CRL #218

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ $(GO_DEPS): go.mod $(PATCHES) swsscommon_wrap
$(GO) mod vendor
$(GO) mod download golang.org/x/[email protected]
$(GO) mod download github.com/jipanyang/[email protected]

$(GO) mod download github.com/agiledragon/gomonkey/v2
$(GO) mod download github.com/godbus/dbus/v5
$(GO) mod download github.com/maruel/natural
$(GO) mod tidy

cp -r $(GOPATH)/pkg/mod/golang.org/x/[email protected]/* vendor/golang.org/x/crypto/
cp -r $(GOPATH)/pkg/mod/github.com/jipanyang/[email protected]/* vendor/github.com/jipanyang/gnxi/
$(MGMT_COMMON_DIR)/patches/apply.sh vendor
Expand Down
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ stages:

popd

apt list --installed | grep golang

apt-cache policy golang

pushd sonic-gnmi

dpkg-buildpackage -rfakeroot -us -uc -b -j$(nproc) && cp ../*.deb $(Build.ArtifactStagingDirectory)/
Expand Down
18 changes: 18 additions & 0 deletions gnmi_server/clientCertAuth.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gnmi

import (
"os"
"github.com/sonic-net/sonic-gnmi/common_utils"
"github.com/golang/glog"
"golang.org/x/net/context"
Expand All @@ -24,6 +25,23 @@ func ClientCertAuthenAndAuthor(ctx context.Context) (context.Context, error) {
return ctx, status.Error(codes.Unauthenticated, "could not verify peer certificate")
}

// [Hua] POC to verify CRL can work
rawCRLs := make([][]byte, 6)
rawCRL, err := os.ReadFile("/etc/sonic/crl/test.crl")
if err == nil {
rawCRLs = append(rawCRLs, rawCRL)
cRLProvider := NewStaticCRLProvider(rawCRLs)
err := checkRevocation(tlsAuth.State, RevocationConfig{
AllowUndetermined: true,
CRLProvider: cRLProvider,
})
if err != nil {
return ctx, status.Error(codes.Unauthenticated, "Peer certificate revoked")
}
} else {
glog.Infof("[%s] [CRL] load /etc/sonic/crl/test.crl failed ; %v", rc.ID, err)
}

var username string

username = tlsAuth.State.VerifiedChains[0][0].Subject.CommonName
Expand Down
Loading
Loading