Skip to content

[Android] Investigate support for SSLStream below API Level 24 #78715

Closed

Description

@steveisok

The block below will throw a PNSE because SNIHostName and SSLEngine.setServerNames are only supported on API level 24 and above.

Here is a sample that can throw the PNSE:

using var client = new TcpClient("login.sequrix.com", 443);
            using var stream = new SslStream(client.GetStream(), false);
            stream.AuthenticateAsClient(new SslClientAuthenticationOptions()
            {
                TargetHost = "login.sequrix.com"
            });
            stream.Read(new byte[100], 0, 100);

We should investigate if there are any alternative approaches.

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Nov 22, 2022
  2. added this to the 8.0.0 milestone on Nov 22, 2022
  3. ghost removed
    untriagedNew issue has not been triaged by the area owner
    on Nov 22, 2022
  4. added and removed
    untriagedNew issue has not been triaged by the area owner
    on Nov 22, 2022
  5. steveisok commented on Nov 23, 2022

    @steveisok
    MemberAuthor

    After looking at this again, it does seem returning UNSUPPORTED_API_LEVEL is heavy handed.

    if (g_SNIHostName == NULL || g_SSLParametersSetServerNames == NULL)
    {
    // SSL not supported below API Level 24
    return UNSUPPORTED_API_LEVEL;
    }

    It does appear that the java SSLEngine can be created with a host name and a port. Not sure how much of the interop we would have to shuffle to accommodate.

  6. rgroenewoudt commented on Nov 23, 2022

    @rgroenewoudt

    This also effects SocketsHttpHandler and ClientWebSocket usage with HTTPS.

    For example:

    var client = new HttpClient(new SocketsHttpHandler());
    await client.GetStringAsync("https://google.com");
    
  7. simonrozsival commented on Nov 28, 2022

    @simonrozsival
    Member

    I digged into it and it seems that we can force APIs 21-23 to do what we want, although it's not very clean. I'll try to open a draft PR so that we can have a discussion if those code changes are acceptable or not.

  8. marek-safar commented on Nov 28, 2022

    @marek-safar
    Contributor

    API23 is 5+ years out of supported version, do we need to support that in net8?

  9. simonrozsival commented on Nov 28, 2022

    @simonrozsival
    Member

    There are still quite a few devices running APIs 21-23 in the wild, around 6.1%. It would be easier to drop support for them, but it should be possible to keep supporting them with relatively little effort.

    image

  10. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Nov 28, 2022
  11. steveisok commented on Nov 28, 2022

    @steveisok
    MemberAuthor

    API23 is 5+ years out of supported version, do we need to support that in net8?

    I'll raise that with the larger team and see if there's a desire to bump the min version. I think this definitely needs to be fixed for .NET 6/7.

  12. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Dec 6, 2022
  13. ghost locked as resolved and limited conversation to collaborators on Jan 5, 2023
  14. karelz commented on May 27, 2023

    @karelz
    Member

    Fixed in main (8.0) in PR #78918 and in 7.0.3 in PR #79280 and in 6.0.14 in PR #79277.

  15. modified the milestones: 8.0.0, 6.0.x on May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions