So this video explains how https works. What I don’t get is what if a hacker in the middle pretended to be the server and provided me with the box and the public key. wouldn’t he be able to decrypt the message with his private key? I’m not a tech expert, but just curious and trying to learn.

  • lostmypasswordanew@feddit.de
    link
    fedilink
    English
    arrow-up
    64
    arrow-down
    1
    ·
    edit-2
    1 month ago

    All TLS/HTTPS clients have a set of Certificate Authority keys which they trust. Your client will only accept a public key which is signed by a trusted CA’s key. A proper CA will not sign a key for a domain when it has not verified that the entity that wants it’s key signed actually controls the domain.

    • mox@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      40
      arrow-down
      2
      ·
      1 month ago

      A proper CA will not sign a key for a domain when it has not verified that the entity that wants it’s key signed actually controls the domain.

      Most browsers trust many certificate authorities from all over the world.

      Any of them could…

      • be compelled by authority
      • be compelled by threat
      • be hacked
      • have a lapse in ethics
      • have a rogue employee
      • etc.

      …and yes, it has happened already.

      HTTPS as most of us use it today is useful, but far from foolproof. This is why various additional measures, like certificate pinning, private CAs, and consensus validation are sometimes used.

      • lemmyvore@feddit.nl
        link
        fedilink
        English
        arrow-up
        21
        ·
        edit-2
        1 month ago

        I urge everybody to read up on CA records in DNS and add them to your domains. They basically say what CA the certs for that domain are supposed to come from. Even if another CA issues valid certs for the domain they would be rejected if they don’t match the CA în DNS. It takes 5 minutes.

      • zeluko@kbin.social
        link
        fedilink
        arrow-up
        13
        ·
        1 month ago

        Thats why we now have certificate transparency reports and CA-records.
        Sure not perfect, but at least with a compliant CA it wont just happen in the dark.
        At some point you have to trust someone.

      • Nightwatch Admin@feddit.nl
        link
        fedilink
        English
        arrow-up
        9
        ·
        1 month ago

        It is indeed true that some CAs have seriously misbehaved; however, browser builders are rather strict on the presence of the CAs they trust. Misbehaving or even simple errors are reasons for getting kicked out, after which certificates signed by those CAs are now no longer valid.

        • mox@lemmy.sdf.org
          link
          fedilink
          English
          arrow-up
          2
          arrow-down
          1
          ·
          edit-2
          1 month ago

          Misbehaving or even simple errors are reasons for getting kicked out,

          That can be helpful if a transgression is noticed, and it’s not orchestrated by a higher authority (e.g. government), and the damage isn’t already done.

          browser builders are rather strict on the presence of the CAs they trust.

          Of course, browser builders are vulnerable to influence, attack, accidents, and blind spots just as certificate authorities are.

        • lily33@lemm.ee
          link
          fedilink
          English
          arrow-up
          2
          arrow-down
          1
          ·
          1 month ago

          I’m somewhat skeptical. What if LetsEncrypt decided to misbehave tomorrow? Would the browsers have the guts to shut it down and break all sites using it?

          • Nightwatch Admin@feddit.nl
            link
            fedilink
            English
            arrow-up
            2
            ·
            1 month ago

            Yes, they will. We’ve seen it before in mostly less serious cases: Diginotar, Türktrust, Symantec, etc. As brittle as the CA system can be, when there is real enough trouble, CAs do get revoked.

      • qwerty@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        10
        ·
        1 month ago

        This is slightly off-topic but I was thinking about it and all of thoes isues can be solved by utilizing blockchain. Imagine a world where instead of CAs, decentralized domain (unstoppable domains, ENS etc.) owners publish their pub keys to the blockchain, the client can than query multiple nodes or store the chainstate locally. When establishing a connection client sends a secret handshake message + clients’ pub key encrypted with domains’ pub key. To complete the handshake server responds with the same secret message encrypted with clients’ pub key.

        • lily33@lemm.ee
          link
          fedilink
          English
          arrow-up
          2
          ·
          1 month ago

          It seems to me like a MITM hacker can just redirect all requests to a Blockchain node towards their malicious node.

  • elrik@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    1 month ago

    As others have mentioned, a trusted 3rd party signs the correct key so your browser can check the key itself.

    However, it should also be noted that your browser must have a list of trusted 3rd parties and their certificates used for signing in order to perform this check. It’s entirely possible to modify this list yourself. Some examples include:

    • executing your own MITM style “*attack” in order to intercept and analyze local https traffic
    • corporate network inspection and monitoring, where a gateway does the above for all devices on the network which have a CA cert pre-installed through some policy

    So while it’s possible for trusted 3rd parties to issue valid certificates to bad actors, it’s also possible to add anyone (you, your employer, or some bad actors) to the trusted parties list.

    • Huschke@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 month ago

      Add Norton to that list. They also perform their own MITM attack on your pc to ensure your certificates are “safe”…

  • NeoNachtwaechter@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    2
    ·
    1 month ago

    It is possible and it has been done.

    You need to get your “hacker” key signed/certified by an official CA. Which is not that difficult with some of them because they are doing it for money.

    • Cras@feddit.uk
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 month ago

      You don’t really ‘need to’ in a world where a good proportion of people will happily click ‘continue anyway’ when they get any sort of certificate error

      • zeluko@kbin.social
        link
        fedilink
        arrow-up
        3
        ·
        1 month ago

        Thats why we have HSTS and HSTS preloading, so the browser refuses to allow this (and disabling it is usually alot deeper to find than a simple button to “continue anyways”)

      • NeoNachtwaechter@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        1 month ago

        people will happily click ‘continue anyway’

        Not possible without a certificate. There will be no TLS connection, only an error message. No ‘click continue’.

        • ferret@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 month ago

          It is trivial for an attacker to make self-signed TLS certs, and you can absolutely just click “continue” on sites that use them when you get a warning from the browser

            • ferret@sh.itjust.works
              link
              fedilink
              English
              arrow-up
              2
              ·
              1 month ago

              I am personally using firefox and referencing my own servers that use their own self-signed TLS certs that I have not bothered to load onto my pc because they aren’t public, but chromium-based browsers aren’t some outlier here

            • Cras@feddit.uk
              link
              fedilink
              English
              arrow-up
              2
              ·
              1 month ago

              Firefox, Chrome, Edge, will all warn you about self-signed certs or cert mismatches but allow you to continue. You’re completely correct that SSL/TLS needs a certificate, but it doesn’t need to be CA issued or in any way legitimate for the encrypted tunnel to be established

  • Mubelotix@jlai.lu
    cake
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    1 month ago

    It should also be mentioned that you can get a CA to sign your certificate just before your domain expires, so you can attack whatever website is going to buy your domain next

  • JakenVeina@lemm.ee
    cake
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 month ago

    An additionap note on what a certificate is, to supplement everyone here who’ve desceibe howbthat’s the missing piece:

    A certificate’s first main purpose is being the vehicle vy which the public key is distributed, but additionally it contains information ABOUT the owner. Then the whole thing is digitally signed with the private key (and also a trusted CA’s private key), so that a receiver can validate the authenticity of the cert with the public key.

    The “info” in the cert can theoretically be anything, but the most important one is the domain. Your browser knows that visiting google.com is secure because it checks the cert it gets from google.com to see if it states that it owns the google.com domain, and then we trust the root CAs around the world to make clients prove they own that domain, before issung a cert for it.