Learning Library

← Back to Library

Understanding Public Key Infrastructure Basics

Key Points

  • The episode introduces public key infrastructure (PKI) by recounting a real‑world scenario of setting up a website’s HTTPS lock icon and the steps involved: generating a key pair, creating a certificate request, obtaining a certificate from a CA, and installing it on the server.
  • Jeff explains that PKI relies on asymmetric cryptography, where a public and a private key are mathematically linked so that data encrypted with one can only be decrypted with the other.
  • The private key must be kept secret; best practice is to store it securely—ideally in a hardware secure enclave that never exposes the key to the operating system or administrators.
  • The public key is meant to be openly distributed; knowing it does not allow an attacker to derive the private key, enabling anyone to encrypt data for the key holder or verify signatures.
  • A common misconception is clarified: the choice of which key is used for encryption versus decryption is arbitrary—the mathematics work either way, so the “public” key isn’t limited to decryption only.

Full Transcript

# Understanding Public Key Infrastructure Basics **Source:** [https://www.youtube.com/watch?v=0ctat6RBrFo](https://www.youtube.com/watch?v=0ctat6RBrFo) **Duration:** 00:09:18 ## Summary - The episode introduces public key infrastructure (PKI) by recounting a real‑world scenario of setting up a website’s HTTPS lock icon and the steps involved: generating a key pair, creating a certificate request, obtaining a certificate from a CA, and installing it on the server. - Jeff explains that PKI relies on asymmetric cryptography, where a public and a private key are mathematically linked so that data encrypted with one can only be decrypted with the other. - The private key must be kept secret; best practice is to store it securely—ideally in a hardware secure enclave that never exposes the key to the operating system or administrators. - The public key is meant to be openly distributed; knowing it does not allow an attacker to derive the private key, enabling anyone to encrypt data for the key holder or verify signatures. - A common misconception is clarified: the choice of which key is used for encryption versus decryption is arbitrary—the mathematics work either way, so the “public” key isn’t limited to decryption only. ## Sections - [00:00:00](https://www.youtube.com/watch?v=0ctat6RBrFo&t=0s) **Understanding PKI Through a Web Setup** - A host shares their experience obtaining an SSL certificate for a website and asks a security expert to clarify public key infrastructure and how asymmetric key pairs work. - [00:03:02](https://www.youtube.com/watch?v=0ctat6RBrFo&t=182s) **Symmetric vs Asymmetric Encryption Overview** - The speaker contrasts symmetric cryptography, which uses a single shared key that is fast but hard to distribute securely, with asymmetric cryptography, which uses paired public and private keys to safely exchange the symmetric key despite slower performance. - [00:06:13](https://www.youtube.com/watch?v=0ctat6RBrFo&t=373s) **Understanding Certificate Authority Chain** - The speaker explains how a trusted third‑party Certificate Authority issues digitally signed certificates that form a hierarchical chain of trust, allowing users to verify authenticity without directly trusting each individual party. ## Full Transcript
0:00Welcome to Tech Talk. 0:01Today's topic is public key infrastructure. 0:04Before we finish, you're going to know what it is, why it's important and how it works. 0:10And with me is Jeff, the security guy. 0:12I want to explain why I wanted to pick up this topic. 0:16Last week I was setting up a web site and I wanted to get a lock icon that people expect in the web browsers. Right? 0:25Because if you don't see that -- in fact, some web browsers, they put up a warning 0:28and say "Hey, are you sure you want to do this?" This could be sketchy, right? 0:32And so I was going through those steps and I pretty much just followed a run book 0:35and that involved first generating like a public and private key. 0:41And then from there I created a certificate request which I sent to a certificate authority. 0:48And then finally I got my certificate, which I then installed on the web server. 0:57But I really didn't understand how it worked. 0:59And so can you explain that to me? 1:01Yeah, sure. 1:02So one of the things that was happening when you did this is you generated this key pair, public and private key. 1:09Well, there's this thing that we call asymmetric cryptography. 1:13Asymmetric 1:14...because there's two keys involved. 1:16They're mathematically related with this special property that whatever you do with one of the keys, 1:21you can only undo with the other. 1:24So if you encrypt the message with one of the keys, then you can only decrypt the message with the other, and vice versa. 1:31Then what you're doing is you arbitrarily choose one of those and say "This one is my private key. 1:39I am going to guard that like the keys to Fort Knox." 1:41It's going to be super secure. 1:44I'm not going to tell anyone. 1:46In my case, I ended up putting it in as a root user. 1:49It was only accessible that way. 1:50Sure. That's a typical way if you're storing it from a software perspective. 1:55An even more secure way to do it would be to store it in hardware on a secure enclave -- 2:01a special chip that never even exposes the key to the storage. 2:08Or even the admin, for that matter. 2:10Exactly. No one can see it. 2:11It stays only inside there, and all of its operations are performed in the secure chip. 2:16Got it. 2:16So let's go on then. 2:17So there's a private key. 2:19That one you keep totally secret. 2:22The public key is just the opposite. 2:24You tell the entire world. You don't care who knows what your public key is. 2:28Because the beauty of asymmetric cryptography is that even if someone knows this, 2:33they have no way to reverse engineer practically to get to that. 2:38So giving that public key information out basically tells the world how they can communicate with you, 2:44but doesn't reveal anything about your private key. 2:48A little true confession here: 2:50I have to admit that I always thought a public key was just doing for decryption, and the other words used for encryption. 2:58Yeah. 2:59You're saying that's not true? 2:59It's not true. 3:00It's a reasonable assumption, but it's not the case. 3:03In fact, the math behind this doesn't know which one you chose is public or private. 3:08It doesn't care. 3:09You encrypt with one, you decrypt with the other. 3:12And it's an arbitrary decision at the time that you designate which is which. 3:16Before we leave that, what would symmetric encryption come into play here? 3:21Yeah. So symmetric cryptography is similar, but different. 3:25With asymmetric we have two keys. 3:27That's the asymmetry. 3:28One's public, one's private. 3:30With symmetric. 3:31We have only one key. 3:34That one key is used to encrypt. 3:36That one key is used to decrypt. 3:38Does double duty. 3:39Exactly. 3:39So it's symmetric. 3:41It has symmetry. 3:41It's the same key on both sides. 3:43If I send you a message that I've encrypted with this particular symmetric key, 3:47the only way you can decrypt it is to use the very same symmetric key. 3:51But that presents a problem for me getting that symmetric key to you, doesn't it? 3:56It absolutely does. 3:57So the advantage to symmetric key cryptography is that it's relatively efficient. 4:02It's fast compared to asymmetric, which is much, much slower. 4:07The downside with symmetric is exactly the problem you said. 4:10If I generate a key and I encrypt a message with it, now I need a way for you to know what that key is. 4:18And if I just sent you the key in an email, someone might intercept it. 4:22If I come up with some other kinds of means to send that to you, then there are all different kinds of problems. 4:28So that's why we use asymmetric cryptography as a way to communicate and transmit the symmetric key. 4:35Oh, I see. 4:36So, for example, if I wanted to get you the symmetric key, I first encrypt it with an asymmetric key. 4:42Send that to you, and then you can decrypt it with my public key. 4:47Exactly. 4:47And then I see. 4:48And then I can you have that now, that symmetric key that we can then use to do fast exchanges. 4:54Exactly. 4:55Okay. 4:55So this is why you can use both, and each one for what it's good for. 5:00So the PKI, the public key infrastructure part, refers to this asymmetric. 5:05And what that really solves for us is the key distribution problem that was left over by using symmetric key cryptography. 5:12Okay, great. 5:12I got that. 5:13So I have that now. 5:14My public private key, I've done my certificate request, which has a bunch of information like the website you're going to use, 5:21the admin contact information, stuff like that. 5:25I fill out that certificate request and it goes to a certificate authority and I get finally my certificate. 5:31What is going on in this certificate that is going to work back on my web server? 5:36What's going on behind the scenes? 5:38So it's important to understand that the main thing that's in your certificate is this: your public key. 5:44That's the information, and the certificate is the way of conveying that. 5:48The certifcate is a way that is a trustworthy way of conveying to the world what your public key is. 5:54Because if I want to send you that message that only you can get, then I've got to encrypt it with your public key. 5:59But how do I know what your public key is? 6:01I'm going to take it from your certificate. 6:03And the certificate authority, which was given my public key, how do they verify, like when I create my web browser, 6:11how does it verify that this actually came from them? 6:13Yeah. 6:14So it's going to ask a bunch of questions and it's going to populate the certificate with your answers to those questions. 6:21But ultimately, if the certificate authority, this guy right here that we refer to as a trusted third party, 6:28the certificate authority is someone that you trust and someone that I trust. 6:33So I don't have to trust you. 6:35I just have to trust the certificate authority that the certificate it gave me is in fact yours. 6:41When you click that log lock icon, it actually shows you a list of all the authorities that were used to authenticate that. 6:48And it shows a trust, a chain of ... 6:51A chain of trust. 6:51Exactly. Because you may have multiple certificate authorities, this certificate authority is trusted by another, is trusted by another, and so forth. 7:01As long as all of those chain of certificate authorities trust each other, then the certs that they issue will be trusted as well. 7:08And I don't have to go back to the certificate authority for each browser request, right? 7:12In fact, you don't. 7:13That's the beauty of this. 7:14You could store all of these in a central database and that could be at the certificate authority. 7:18But it doesn't have to be. 7:20You could, in fact, store these certificates anywhere. 7:23I could send it to you in an email. 7:24It doesn't matter how I get it to you, as long as I get it to you. 7:27The information in here is secure and we know it's secure because it was vouched for by the CA. 7:33So they had a signature on it. 7:35That's where we get this thing we call a digital signature. 7:39Right? 7:39I've heard that phrase used quite a bit. 7:42Can you explained that to me? 7:43Yeah. 7:43So with a digital signature, that's the way the CA, once it's been satisfied that this is in fact your actual cert, 7:51and that that is in fact your public key, and you are in fact who you claim to be, 7:55then the CA will basically sign that all of these things are true. 8:02The way it does that is it runs a special algorithm against the cert, a thing called a hash. 8:08So we have a hashing algorithm that's run that summarizes the information here. 8:13If anything changes in here, the hash value would change dramatically. 8:18So the CA runs this hash to verify what the message is. 8:23Then it uses, guess what? 8:25It's private key to encrypt that hash value. 8:28Which I can then decrypt with ... 8:31Yes. 8:31The public key. 8:32Exactly. 8:33You know, the CA's public key because it's baked into your browser in advance. 8:38So that's how the whole process bootstrapped. 8:40And so we're using the same techniques that we're using to communicate the keys. 8:44We're using that same PKI infrastructure in order to do digital signing and in order to create a system of trust. 8:51I think we've covered it now. 8:53That was the how, the why, and the what. 8:56So there it is, we're gonna wrap on that. 8:59If you'd like to see more tech talks, maybe with Jeff, or on other topics, be sure and leave us a comment below. 9:06And also please remember to subscribe so we can keep bringing you cool content like this. 9:12Thanks for watching. 9:14If you'd like to see more videos like this in the future, please click Like and Subscribe.