0

Trying to use CurlThin (for HTTPS calls with specific ciphers), following Adding Cipher suite to TLS1.2 of HttpClient of dotnetcore 3.1 sample, but if I put SSL_CIPHER_LIST option, the following CurlNative.Easy.Perform() call leads me to an (uncatched) AccessViolationException. What is wrong with code?

<!-- language: lang-none -->
Try
    CurlResources.Init()
    Dim globale = CurlNative.Init()
    Dim easy = CurlNative.Easy.Init()
    Try
        Dim dataCopier As New DataCallbackCopier()

        CurlNative.Easy.SetOpt(easy, CURLoption.URL, "https://XXX/api/MaFonction")
        CurlNative.Easy.SetOpt(easy, CURLoption.WRITEFUNCTION, dataCopier.DataHandler)

        This string Is needed when you call a https endpoint.
        CurlNative.Easy.SetOpt(easy, CURLoption.CAINFO, CurlResources.CaBundlePath)

        Your set of ciphers, full list Is here https://curl.se/docs/ssl-ciphers.html
        Dim repCL As CURLcode = CurlNative.Easy.SetOpt(easy, CURLoption.SSL_CIPHER_LIST, "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384") 'Here result is "OK" as expectd

        Dim result As CURLcode = CurlNative.Easy.Perform(easy)  'Exception occurs here
        content = Encoding.UTF8.GetString(dataCopier.Stream.ToArray())

    Catch ex As Exception
        content = ex.Message
    Finally
        Try
            easy.Dispose()

            If globale = CURLcode.OK Then
                CurlNative.Cleanup()
            End If
        Catch ex1 As Exception
            content = ex1.Message
        End Try

    End Try
Catch ex2 As Exception
    content = ex2.Message
End Try

Return content
Shubham Takode
  • 525
  • 8
  • 24

0 Answers0