2

Maybe I'm asking absolutely dumb question, but I couldn't find the answer yet. I know when I'm sending or getting a data in a browser over https, both server and client (browser) checks each other certificates. If everything is ok the data transfer starts.

Now I wonder how to handle all this stuff in my code? I'm using some framework which allows me to download data. When I'm specifying an address as https://... I downloading stuff. But I didn't specify any certificates (I don't have any!). So how does it works in my case? Is it really https?

Here's an example that confused me: I have some file in dropbox. I can download it with my code if I specify https address. But also I can download the same file if I specify just http!

  • 1
    Client authentication in SSL/TLS is possible, but generally over the web no one does it. What's important is that you verify the certificate chain of the server. Websites like DropBox allow users to connect over either HTTP or HTTPS. It's up to the users to ensure that they choose the secure option. – RoraΖ Jan 29 '15 at 13:33
3

If you are trying to write code for downloading data over TLS(SSL) you should consider if you know which hosts you are downloading from and use a technique caled certificate pinning.

Cert. pinning is hard-coding the certificate of the server you are connecting to in your code and only accepting the connection if it is made over TLS using the expected certificate. OWASP explains the concept here: https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning

But basically it comes down to you explicitly verifying the different details of the connection you are setting up. More information about the framework and scenario would help.

  • I'm using Qt framework. It allows to download via https. Let's say I want to download from dropbox https. And I wonder - do my application needs to be certified or this is only for server? And who should check server certificate - framework? If I specified download address as https, do I really use secure connection? – nikitablack Jan 29 '15 at 14:39
  • 2
    Have never used QT, but the server has a certificate, you do not need your own. But from the docs it seems you could use the doc.qt.io/qt-5/qsslconfiguration.html#peerCertificate function to get thee peer certificate and verify that it is the one you expected if you want do to cert. pinning. Other that that just make sure that you only accept strong ciphers, and that any failure to set up TLS does not result in fallback to http. QT-specific help should come from someone wit QT-experience. – vidar Jan 29 '15 at 14:48
1

You need to bundle together trusted CA root certificates in your application, especially if you're contacting 3rd party https websites. Major browsers verify websites using bundled certs with the application, or the OS. The browser then checks the received cert is signed by one of the stored root CAs.

You'd then need to do the same thing browsers do, and verify the received certificate is signed by a major CA.

Certificate pinning can work for your OWN server with a self signed certificate and you don't wish to purchase a commercially signed certificate. But it's a very poor solution for a 3rd party where the certificate can change without notice. Certificates expire, can be revoked, or suddenly replaced for whatever reason, and then suddenly your application won't work until you update everyones application. That's a poor solution.

  • "This is how major browsers verify websites", I recall only Firefox doing this. Safari, Chrome and IE all use the system certificate store instead of their own. – Siyuan Ren Jan 30 '15 at 7:08
  • I disagree to the fact that Certificate pinning is a poor solution. If you are concerned with connecting to the correct party this is the best way to do it; yes you have to be ready to react to cert. changes. The basic problem remains the same albeit perhaps a bit smaller by bundling root CAs. Suddenly the site you are connecting to changes cert delivery to the cheapest cert of today and you need new roots, some CA is compromized and you should remove it from your trust store etc. But either way works, just depends on the threat model. – vidar Jan 30 '15 at 9:37
  • @SiyuanRen You're right, they do. I'll change the answer. – Steve Sether Jan 30 '15 at 15:29
  • @vidar Being ready for certificate changes is a major problem. You have to update your app every time a certificate changes, or download new certs. In either case you have to have a secure means of doing that. How is that channel secured? Bundling root CAs is a much smaller problem, as root CAs live decades, which is longer than the lifetime of your application. I truly don't understand the preference for certificate pinning here over simply verifying the certificates with trusted root CA, which was how SSL was designed to work. – Steve Sether Jan 30 '15 at 15:34
  • @Steve I agree, and just indicated the possibility. If you trust the CA-chain approach using the framework is sufficient. But if you want to be sure that you are on TLS(SSL) you need to make sure that you are using adequate ciphers and handle failure to verify the connection. I prefer pinning as that also complicates analysis from "interested third parties" But much easier when you control both app and servers as you say. Also there is the digiNotar case en.wikipedia.org/wiki/DigiNotar – vidar Feb 2 '15 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.