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

Add cert CRL support. #269

Merged
merged 9 commits into from
Nov 20, 2024

Conversation

liuh-80
Copy link
Contributor

@liuh-80 liuh-80 commented Jul 9, 2024

Add cert CRL support.

Why I did it

Support certificate revocation list.

How I did it

Download CRL and verify cert with CRL.

How to verify it

Manually test:

I1119 06:45:56.678454 139 server.go:201] Created Server on localhost:50052, read-only: true
I1119 06:45:56.678478 139 telemetry.go:465] Auth Modes: cert
I1119 06:45:56.678495 139 telemetry.go:466] Starting RPC server on address: localhost:50052
I1119 06:45:56.678532 139 telemetry.go:469] GNMI Server started serving
I1119 06:46:14.936024 139 clientCertAuth.go:183] Get Crl Urls for cert: []
I1119 06:46:14.936363 139 clientCertAuth.go:224] Cert does not contains and CRL distribution points
I1119 06:46:14.936375 139 server.go:278] authenticate user , roles [role1]
I1119 06:46:21.524943 139 clientCertAuth.go:183] Get Crl Urls for cert: [http://10.250.0.102:1234/crl]
I1119 06:46:21.526022 139 clientCertAuth.go:93] SearchCrlCache not found cache for url: http://10.250.0.102:1234/crl
I1119 06:46:21.526138 139 clientCertAuth.go:158] Download CRL start: http://10.250.0.102:1234/crl
I1119 06:46:21.533821 139 clientCertAuth.go:176] Download CRL: http://10.250.0.102:1234/crl successed
I1119 06:46:21.534318 139 clientCertAuth.go:66] CrlExpired expireTime: Wed Nov 20 06:46:21 2024, now: Tue Nov 19 06:46:21 2024
I1119 06:46:21.534337 139 clientCertAuth.go:211] CreateStaticCRLProvider add crl: http://10.250.0.102:1234/crl content: [...]
I1119 06:46:21.535269 139 clientCertAuth.go:244] VerifyCertCrl peer certificate revoked: no unrevoked chains found: map[2:1]
I1119 06:46:21.535289 139 clientCertAuth.go:149] [TELEMETRY-2] Failed to verify cert with CRL; rpc error: code = Unauthenticated desc = Peer certificate revoked

Add new UT.

Work item tracking

Microsoft ADO (number only): 27146924

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Add cert CRL support.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@liuh-80
Copy link
Contributor Author

liuh-80 commented Jul 15, 2024

Will verify this change with sonic-net/sonic-buildimage#19536

@liuh-80 liuh-80 changed the title [POC] Add cert authorization with common name support. Add cert authorization with common name support. Aug 22, 2024
@liuh-80 liuh-80 marked this pull request as ready for review October 8, 2024 00:14
@liuh-80 liuh-80 requested a review from ganglyu October 8, 2024 00:14
Makefile Outdated Show resolved Hide resolved
return ctx, nil
}

func TryDownload(url string) bool {
Copy link
Contributor

@ganglyu ganglyu Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to download crl from external url, we need to make sure dns is working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no external url, I verified the dns is working.

func VerifyCertCrl(tlsConnState tls.ConnectionState) error {
// Check if any CRL already exist in local
crlUriArray := GetCrlUrls(*tlsConnState.VerifiedChains[0][0])
downloaded := DownloadNotCachedCrl(crlUriArray)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If crl is enabled, but we failed to download crl, all the gnmi requests will be rejected.
Is this acceptable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's by design:
If a cert does not contains any CRL distribution points, cert will not verify by CRL.
If a cert contains multiple CRL distribution points, and download from all distribution points failed, then the cert should be blocked, because we can't verify it.

Makefile Outdated Show resolved Hide resolved
@liuh-80
Copy link
Contributor Author

liuh-80 commented Oct 24, 2024

/azpw run sonic-net.sonic-gnmi

@mssonicbld
Copy link

/AzurePipelines run sonic-net.sonic-gnmi

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80 liuh-80 changed the title Add cert authorization with common name support. Add cert CRL support. Nov 4, 2024
@liuh-80
Copy link
Contributor Author

liuh-80 commented Nov 4, 2024

/azpw run sonic-net.sonic-gnmi

@mssonicbld
Copy link

/AzurePipelines run sonic-net.sonic-gnmi

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80 liuh-80 force-pushed the dev/liuh/disable-crl-cert-access branch from a9de39f to 65e9e5f Compare November 11, 2024 09:15
@liuh-80
Copy link
Contributor Author

liuh-80 commented Nov 18, 2024

Will verify with this image:
sonic-net/sonic-buildimage#19536

@liuh-80 liuh-80 merged commit e6bc0e7 into sonic-net:master Nov 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants