Using valid HTTPS certificates in local development with Linda Ikechukwu
PodRocket
- August 4, 2023
- 34 min
About this episodeLearn about HTTPS certificates and how they affect development with Linda Ikechukwu. Links https://smallstep.com/docs/step-cli…
Learn about HTTPS certificates and how they affect development with Linda Ikechukwu.
Linkshttps://smallstep.com/docs/step-cli
https://twitter.com/_mslinda
https://www.linkedin.com/in/linda-ikechukwu
https://www.codewithlinda.com
https://www.everythingtechnicalwriting.com
https://github.com/Linda-Ikechukwu_
We want to hear from you! We want to know what you love and hate about the podcast. What do you want to hear more about? Who do you want to see on the show? Our producers want to know, and if you talk with us, we’ll send you a $25 gift card!
If you’re interested, schedule a call with us or you can email producer Kate Trahan at kate@logrocket.com
Follow us. Get free stickers.Follow us on Apple Podcasts, fill out this form, and we’ll send you free PodRocket stickers!
What does LogRocket do?LogRocket combines frontend monitoring, product analytics, and session replay to help software teams deliver the ideal product experience. Try LogRocket for free today.
Special Guest: Linda Ikechukwu.
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Using valid HTTPS certificates in local development with Linda Ikechukwu
Hi there. And welcome to PodRocket, a web development podcast brought to you by LogRocket. LogRocket helps software teams improve user experience with session replay, error tracking, and product analytics. Try LogRocket. com today. My name is Paul and joined with me is Linda Ikechukwu. She is a developer advocate over at Smallstep Labs and is an active educator in the space, spreading knowledge of infrastructure and security. So we're here to talk about her latest talk from this year's React Summit called Bring Development Closer to
Yeah we're excited to have you. Cause this is a topic that I'm sure you've seen Linda. It gets glossed over all the time. It's like HTTP and HTTPS. It's one of those things in the back of our minds. And it could be slowing us down or hindering the way we are mentally modeling the way we're developing.
Yeah, sure. Hi everyone. My name is Linda Ikechukwu. And like Paul mentioned, I'm a developer advocate at SmallStep Labs. And SmallStep is in a nutshell in the business of making it easy. For teams to secure distributor systems with TLS certificates and as a developer advocate, my duty is to try to right now I'm very much active in the which stands for public key infrastructure ecosystem and just trying to educate about how certificates can be used.
To secure systems and just help developers because PKI is a very strange and quite complicated them and like fields. So we're just trying to. Yeah, abstract that layer for developers and so they can focus on what they do best, which is building stuff while we take care of things behind. So that's where I am at the moment.
Well, Thank you for joining us. I'm sure there's going to be some folks listening that maybe it's their. First time even considering throwing HTTPS on localhost, which I know is something we're going to be talking about. If somebody were to say, Hey, okay, I know HTTP, HTTPS, and TLS have worked with this before.
Usually it's considering the knowledge level of folks that I am my audience and a major audience are usually DevOps engineers and IT infrastructure guys. They have much more knowledge about PKI because they have to interface with servers and devices a lot. But when my audience are front end developers, I try to keep it down a notch and simplify everything because I know that for front end developers, it's just to build stuff that people get to see and they don't have to interact with servers and devices that much.
Yeah. So one of the main principles of software development is to maintain dev prod parity, and that's basically means to keep production staging and development as similar as possible. To avoid running into undetected bugs, because, if your development environment or your staging environment is far off different from production environment, then it will be difficult for you to replicate errors that you come across on production in staging or development to fix it.
uh, this talk is just based on the premise that. If your production website runs on HTTPS, then it makes sense that your development environment and your site should also run on HTTPS so that you can easily replicate bugs that arise due to, HTTPS complications on production and replicate it in development.
for, um, majority of instances and use cases, local host does actually behave like HTTPS. But there are some cases in which it doesn't. And you have cases where there's like miscontent. Uh, A couple of frontend developers might have run into, mis content errors where your page is composed of content delivered through HTT p s and content delivered through H T T P.
, Because you probably use like a JavaScript library from a http based c d n or it could be, , you need to locally test third party APIs or libraries that require he c P S. Now, you can't do that on localhost. , Other scenarios where localhost does not behave like HTTPS when you need to test secure, cookies across browsers.
And secure cookies only run on HTTPS, but don't run on localhost for all browsers. So if you're dealing with special situations like this or use cases like this, then you definitely need to set up HTTPS on your local development because , you wouldn't be able to identify and resolve these issues with just local host.
Gotcha. So it seems like there's two angles here that we're talking about where it's productivity for the developer, you know, parity between your local and production environment, but there's also some tangible setup that needs to happen in order for some of this development that you're describing to actually take place on the local host, whether that be interfacing with CDNs, APIs, et cetera.
So I think one barrier is that, usually , for production and like for staging um, , most developers would usually use a public web, certificate authority, and the most popular one is less encrypts that automates like. Certificate issuance and renews every 90 days. But then the problem is that you can't use, something like less encrypt for your local dev environments the World Wide Web Consortium, which is like the body in charge of, that makes decisions on how the web runs and all that prohibits public web CAs from issuing certificates to.
, Local environments. So you can't make use of a public see like, less encrypt. So I think that will be one challenge because it's setting up a production site to run on HTTPS. HTTPS using less encrypt is quite straightforward and very easy, , but if you want to do that for your local environment, then that becomes a bit impossible and you have to find alternatives, which is what I'm here to talk about.
Awesome. So before we hop into talking about those alternatives and that which is offered by small step to make it easier could we run through the example of like what let's encrypt looks like if folks like haven't gone through the process of doing an HTTPS the way it's traditionally done, and that can maybe help us orient HTTP.
And. The difference between that , I would hope to highlight. So if we were setting it up on, you know, let's encrypt on a production server, there would be some steps such as interfacing with the CA authority, changing some TXT or CNAME records in your DNS configuration. I was wondering if you could walk us through that hierarchy so we can just understand the players that come into
To explain this, it just comes down in how HTTPS works. So HTTPS stands for Secure Hypertest Transfer Protocol, and it's just a step ahead of HTTP. And... When you type in a URL into a browser and see the padlock sign, that means that a HTTPS connection exists between the web server that you're, Retrieving information from your browser and a couple of parties involved in making this happen.
I don't want to get into complicated details because there are a lot of, things involved in making this work, but if you want to get uh, certificate from a certificate authority, first, you request one and , that's the server request one, every server that you visit that has the padlock sign on has a digital certificate, So the server request one and the certificate authority sends like a challenge for it to solve to verify that it's, um, has the control.
So that's when you see make some changes to your DNS file, you know, add like a test document or something, TST documents. That's part of the challenge that the certificate authority is sending. For you to verify that this server has control over this domain name that you're trying to secure, get a certificate for.
So that happens, and when you successfully modify your DNS file and solve the challenge, and then a certificate is provisioned for that server. And so on the client side the browsers have been pre set up with, um, a couple of certificate authorities that they are to trust. So when it's, a client reaches out to a web server to retrieve information, it first asks for, its certificate that if it has been specified that it's running on HTTPS and the server presents that certificate to the client and the client goes through its list of, certificate authorities to check if it has that particular certificate authority that issued the certificate for the server.
Linda, thank you so much for walking us through that, that interaction pattern. I think there's a lot of people listening that would find it refreshing and informative to really highlight those fundamentals when we look at the differences in how we can make this happen on the local host and just to pave over some of these details to make sure I understand.
Only issues certificates to publicly accessible domains or websites, and then privacy is used to issue certificates and enable HTTPS for private domains, you know, domains will be assessed um, without like a public internet connection. So , that's the basic difference between them. So if you're within a cloud environment or within your cloud environment and have an internal sign, that means that that's.
gotcha. And I'm sure this is a good basis. Maybe to now jump off. Cause I, my brain's already buzzing about okay, this feels internal signing and stuff. It feels like we're thinking in the right direction of how to make this work on local host, which is sort of the topic of the talk you gave at react summit.
So before we hop into talking about Small step and step CA, step C live, we're going to get into those tools offered. I just want to remind our listeners that this podcast is brought to you by LogRocket. So if you are developing locally or you're developing on the team in your staging environment, you're trying to squash bugs, find errors faster.
You can use LogRocket to surface different analytics, trends and patterns and find things that you didn't think you could find. So you can spend more time building your app and less time. debugging, less time in the console, less time digging through all sorts of different error logs that you might get from your front end application.
So head over to log rocket. com today to try it for free. So for folks developing locally, Linda you're, pushing forward to this narrative of dev productivity parity, and we want to get HTTPS on local hosts. We talked about some reasons why the beginning and Small step really offers, these things called step dash ca and we talked about CAS and step dash c l i and I'm guessing that's a c l I for us to sort of bundle these tools together and work together.
certificate authority for private networks. So I I already explained the difference between, public certificate authorities and private certificate authorities and mentioning the limitations, why, public certificate authorities cannot be used in internal networks. And if anybody is interested, I have written a blog post on the, three different strong reasons that prohibits public CAs from being used in private networks, which brings the need for internal CAs like StepCA. So you can either self host StepCA and use that to issue certificates within your private network. And So , that's what StepCA is for. Now, since public CAs cannot be used to issue certificates to internal networks and local environments, then you need to set up your own CA. I have to mention that you can totally create a TLA certificate for your local environment without a CA.
In such cases, remember that I mentioned that a CA issues certificates and acts as a root of trust, or in other words, signs a certificate. Now, in such cases, issuing a TLS certificate for your local environment without a CA, you'll be signing the certificate by yourself. And the problem with that is that for self signed certificates, , there's no route of trust to verify that , the origin server is who it claims to be.
And then again, browsers don't consider self signed certificates trustworthy. And we still mark it as not secure. Despite it's running on HTTPS. And so that may also be an issue where you will not be able to replicate. errors that occur in production and I think this is an issue with, the using Gatsby's HTTPS flag because when you use Gatsby's HTTPS flag, what you get is a self signed certificate.
And that's why most times, using Gatsby's flag, you still get the error of like this site is not secure. So what the, um, recommended way is to create your own offline local certificate authority. Get your system to trust that certificate authority, and then use that certificate authority to issue certificates for your, local sites and local environment.
Um, Now that might sound like a lot, but with uh, , open source tools, steps here and steps, c l I, that's. You can achieve this in like five steps. So like I mentioned, Step CA is an open source certificate authority and Step CLI is just a CLI tool that makes it easy for you to interface with Step CA.
So first of all, you would need to, of course, install Step CLI and Step CA. They are available with, um, in different packages. If you're on a Mac, you can just install using the command brew install step. But if you're on Windows or, Linux, then you can find installation instructions on our docs, which link will be included in the.
So that one command installs Step CA and Step CLI. And then the next thing would be to create and configure a local certificate authority on your device. And that happens by running the command Step CA init. Um, , You'll be presented with a couple of options to fill out. , First one would be to ask what you would like to name your new PKI OCA and you can literally name it anything.
And then to ask you just a couple of other things, ask you for a password and after you've. Provided with all that information, you will have a CA ready to go. And then the next step after initializing a CA would be to install the CA root certificate into your system trustor. Now remember that I mentioned that a certificate authority usually acts as a root of trust.
And that's why it's much more preferable over self signed certificates. And to get your, you need to get your device to trust your local CA so that when you visit a web browser or try to assess it, when you visit your local projects on a web browser, it doesn't come up with the error of this URL is not secure.
And so, to install your CA, it will certificate on your device to get your local environment to trust. VCA is using the command step certificate install, and then we path to the CA certificate, which will be provided to you in the previous step when you initialize the CA. So this might be a lot to follow cause it's just audio, but then I have a video about this and that will be provided.
Um, on the page of this podcast. So if you want to follow along, you can just follow along. And then after that, the next step is just to start the CA server. And you start that by running the command step CA, and then the part where the CA is hosted. And when you start your server, , now this is the time when you create a certificate.
Okay. So if I may step in for a moment, Linda, just to summarize where we're at so far. We're going to be running brew install step, which is going to give us step CA and step CLI. You can run and set up the certificate authority. You can take the roots. The root of trust, for the CA, and we have to add it into our OS, our operating system.
So, um, , each device has like a system trust store. And you can do a Google search to check how to assess that. And if you check it, you, you see a list of all sets of public certificate authorities that your devices trust. So what you would just be doing is just adding that local certificate authority to that list, and once it's there, um, even um, tools like Call will trust certificates, from that certificate authority, so you don't need to do any other setup.
You're just, , issuing a certificate by yourself. It's called the self signed certificates. And that's why most times when you still visit your local sites. That has the HTTPS flag enabled, you still get, the browser error that says something like, Oh, this page is not secure because you're using a self signed certificate.
What minimizes the parity is when you get a certificate for your local environment. Now your local environment is running on HTTPS, which mirrors exactly how your production HTTPS site is running because your production HTTPS site has a certificate from a certificate authority. Now your local, um, web server or your local environment now also has a certificate.
From a certificate authority. So whatever issues you have on production, you can easily replicate on local because now your local mirrors exactly how your production is running. And when I was talking about the steps to get, um, a certificate from your local CA that we've just talked about how to set up. so you just go to your React or like your Node. js server. And there's a, create server function, Node. js has the create server function where you would just easily insert the certificates that was created in the previous steps. I talked about how you would just run a command to create a certificate and a private key.
And when you do that, using steps here. It gives you a certificate file and a private key file, and you just go to your Node. js server and insert those two files into the create server function under the set and key properties. and you get those files into your project folder, obviously, so you can easily reference the parts.
great. Okay, thank you for walking us through that. . So just to wrap up some of these ideas that we're talking about HTTP and HTTPS, what do you think is the number one lack of understanding or maybe misconception that developers have, or you could foresee them having when they try to Run with HTTPS on their local environment or maybe it could be like TLS and HTTPS in general as an
So, um, why I, I I am from questioning a couple of devs using HTTPS in local is not very commonplace and that's usually because, Without the help of public CAs like LessEncrypt that automates the entire process of getting a certificate, trying to get a certificate manually using a tool like maybe OpenSSL is incredibly complicated, and that might not be something that most front end developers will have to deal with.
So that's why this practice isn't exactly commonplace, although it helps. When you run into certain issues, like I mentioned in the beginning. So it's that sense of difficulty that makes this not commonplace. And that's where steps here comes in because it's handles everything. it gives you the experience of using less encrypts, but on your local environment.
That's what we want to do build stuff spend more time building stuff and less time debugging the tools that are being put out today are really lending themselves to doing that, just like log rocket, spend less time in your web console. So you're trying to have people spend less time with the SSL primitives, which is fantastic, because I know many of engineer have bashed their heads against the desk, needing to debug those things.
Oh Okay, so right now I don't actively blog. I maintain an active blog, but that's on a totally different topic That's about it's for Folks who are trying to pick up, technical writing as a career you know, advance their technical writing career, because most of what I do in my job is really technical writing and trying to explain complicated.
Concepts to people using simple language. So I blog a lot about the concept of technical writing and that website is called everythingtechnicalwriting. com. But apart from that, you can find me on Twitter at underscore Miss Linda. I don't have a personal website yet. I would get to that soon, I guess.
