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

Incorrect nullability declaration with return value of LocalCertificateSelectionCallback delegate #110444

Closed
CarlG12 opened this issue Dec 5, 2024 · 1 comment · Fixed by #110479
Labels
area-System.Net.Security in-pr There is an active PR which will close this issue when it is merged

Comments

@CarlG12
Copy link

CarlG12 commented Dec 5, 2024

Description

Based on the documentation of the delegate "LocalCertificateSelectionCallback", the return value can be null. However, the delegate is declared to return a notnull X509Certificate.

Link to the documentation:
https://learn.microsoft.com/en-us/dotnet/api/system.net.security.localcertificateselectioncallback?view=net-8.0

Reproduction Steps

Create a project with nullable warning enabled that implements the sample code defined in the documentation of delegate LocalCertificateSelectionCallback.

Compile the project and you will get a nullable warning with return value of SelectLocalCertificate.
If you declare the SelectLocalCertificate to return "X509Certificate?" instead of "X509Certificate", you get a warning when instantiating SslStream object.

Expected behavior

The declaration of LocalCertificateSelectionCallback delegate shall indicates that return value can be null.
Documentation of the delegate is updated.

Actual behavior

The declaration of LocalCertificateSelectionCallback delegate indicates that method return a non-null value.
The sample code return a null value. The impact that we get a nullable warning when we implements this delegate.

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 5, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 5, 2024
@vcsjones vcsjones added area-System.Net.Security and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Dec 5, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Dec 6, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Net.Security in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants