0

I'm working on a mobile application which is sending requests to a public API builds by my company and use a valid certificate to make a secure connection from my side every time im trying to make a request handshake exception unable to get local issuer certificate appears and when I run this command out

openssl s_client -showcerts -servername pub.dartlang.org -connect pub.dartlang.org:443

the output showes below

    CONNECTED(00000003)
    depth=1 C = US, O = Let's Encrypt, CN = Let's Encrypt Authority X3
    verify error:num=20:unable to get local issuer certificate
    ---
    Certificate chain
     0 s:/CN=pub.dartlang.org
       i:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
    -----BEGIN CERTIFICATE-----
   ....
    -----END CERTIFICATE-----
     1 s:/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
       i:/O=Digital Signature Trust Co./CN=DST Root CA X3
    -----BEGIN CERTIFICATE-----
   ...
    -----END CERTIFICATE-----
    ---
    Server certificate
    subject=/CN=pub.dartlang.org
    issuer=/C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
    ---
    No client certificate CA names sent
    Peer signing digest: SHA256
    Server Temp Key: ECDH, P-256, 256 bits
    ---
    SSL handshake has read 3055 bytes and written 456 bytes
    ---
    New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
    Server public key is 2048 bit
    Secure Renegotiation IS supported
    Compression: NONE
    Expansion: NONE
    No ALPN negotiated
    SSL-Session:
        Protocol  : TLSv1.2
        Cipher    : ECDHE-RSA-AES128-GCM-SHA256
        Session-ID: 6E905904FEF3D9B5BA45A2F9140CD2DEC8F31F762759AB2193FD0649585348C9
        Session-ID-ctx: 
        Master-Key: B7762B8FC1543749F02A0011ABBEC22E2C29CA0089F5A4410CCFDE2DB2F1067CED0D8496522292A0338E855E3C717B4E
        Key-Arg   : None
        PSK identity: None
        PSK identity hint: None
        SRP username: None
        Start Time: 1571919503
        Timeout   : 300 (sec)
        Verify return code: 20 (unable to get local issuer certificate)
    ---

    read:errno=0 

how to solve this - I don't want to use a code which trusted all certificates - I don't want to add my certificate to an asset folder

any other solution? like adding my certificate to a flutter trusted store?

Tabarek Ghassan
  • 716
  • 15
  • 28
  • How is showing the certificate of `pub.dartlang.org` relevant to your company's server? There are a number of solutions. Getting the server's cert signed by a CA that is already trusted. If you use an in-house CA you don't have much choice but add the CA's cert to assets and add that as another trusted root. The final choice is to verify the server certificate yourself in code: does it have the right signature, etc. – Richard Heap Oct 27 '19 at 14:53
  • Possible duplicate of [How to do SSL pinning via self generated signed certificates in flutter?](https://stackoverflow.com/questions/51323603/how-to-do-ssl-pinning-via-self-generated-signed-certificates-in-flutter) – Richard Heap Oct 27 '19 at 14:55
  • I already have the server's cert signed by a CA that is already trusted @RichardHeap – Tabarek Ghassan Oct 28 '19 at 06:33
  • So, what's the problem? Update the question with the code and error. – Richard Heap Oct 28 '19 at 11:57

1 Answers1

0

I solved this issue by using httpClient to trust my certificate by adding my root and chain certificate depending on the same code here Flutter add self signed certificate from asset folder

Tabarek Ghassan
  • 716
  • 15
  • 28