<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mariano Matayoshi</title>
    <description>The latest articles on DEV Community by Mariano Matayoshi (@matayoshimariano).</description>
    <link>https://dev.to/matayoshimariano</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F471468%2F04902553-a41d-4d5a-9c91-4dc6ade6865b.jpeg</url>
      <title>DEV Community: Mariano Matayoshi</title>
      <link>https://dev.to/matayoshimariano</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matayoshimariano"/>
    <language>en</language>
    <item>
      <title>How to add SSL to your localhost development environment using Ruby on Rails with Puma</title>
      <dc:creator>Mariano Matayoshi</dc:creator>
      <pubDate>Mon, 21 Sep 2020 12:22:50 +0000</pubDate>
      <link>https://dev.to/matayoshimariano/how-to-add-ssl-to-your-localhost-development-environment-using-ruby-on-rails-with-puma-14di</link>
      <guid>https://dev.to/matayoshimariano/how-to-add-ssl-to-your-localhost-development-environment-using-ruby-on-rails-with-puma-14di</guid>
      <description>&lt;p&gt;Hi readers!&lt;/p&gt;

&lt;p&gt;Well, with the new update from Chrome from 80, if we have third party cookies you will need to add theSameSite=None; Secure , but this means that third party cookies will only be sent over HTTPS connection.&lt;/p&gt;

&lt;p&gt;The following video is explaining this way better than me:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/GPz7onXjP_4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Also, I leave you guys a &lt;a href="https://blog.chromium.org/2020/02/samesite-cookie-changes-in-february.html" rel="noopener noreferrer"&gt;blog post&lt;/a&gt; from Chrome with the SameSite Cookie Changes.&lt;/p&gt;

&lt;p&gt;OK, so if you are like me, who is developing services that shared a cookie between each other and using Ruby on Rails with Puma as your web server you will need to have HTTPS connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a certificate
&lt;/h2&gt;

&lt;p&gt;So the first thing you will need to do is to create a certificate for your service you want to add the HTTPS connection. Let's use &lt;a href="https://github.com/FiloSottile/mkcert" rel="noopener noreferrer"&gt;mkcert&lt;/a&gt; to generate it, i'm going to localhost, but you can use whatever name you want&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

➜  ~ mkcert localhost
Using the local CA at "/Users/marianomatayoshi/Library/Application Support/mkcert" ✨
Warning: the local CA is not installed in the system trust store! ⚠️
Warning: the local CA is not installed in the Firefox trust store! ⚠️
Run "mkcert -install" to avoid verification errors ‼️
Created a new certificate valid for the following names 📜
- "localhost"
The certificate is at "./localhost.pem" and the key at "./localhost-key.pem" ✅


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Now we should mark these cert as trusted, I'm working on a Mac computer, so not sure how to handle this particular part on Windows or on a Linux distro.&lt;/p&gt;

&lt;p&gt;For Mac users open the Keychain Access and drag the certificate to the Keychain, the localhost.pem file, you could see some error, but it will end up adding it..&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F1%2AOiXNKaFGmTbptpoyle-q_A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1400%2F1%2AOiXNKaFGmTbptpoyle-q_A.png" title="Just after adding the certificate" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Double-click the cert you just added, click the -&amp;gt; Trust&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2A_g6l5TM5aVchadlrktqKuA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2A_g6l5TM5aVchadlrktqKuA.png" alt="alt text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2Ab4uUZ8D35MnOdvUv3Dm6oA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2Ab4uUZ8D35MnOdvUv3Dm6oA.png" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And at the &lt;strong&gt;When using this certificate&lt;/strong&gt;: select the &lt;strong&gt;Always Trust&lt;/strong&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2AcmmqC2nAThG4nP5LXR74JA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2AcmmqC2nAThG4nP5LXR74JA.png" alt="alt text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2A-SkYAFgMiFO9wDjMd9DtHw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1200%2F1%2A-SkYAFgMiFO9wDjMd9DtHw.png" title="Always trust the certLocalhost on SSL"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Localhost on SSL
&lt;/h2&gt;

&lt;p&gt;Now the interesting part:&lt;br&gt;
In your puma config you will want to have something like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;I ended up creating a &lt;code&gt;local-certs&lt;/code&gt; folder inside &lt;code&gt;config&lt;/code&gt; folder and pasted the cert and key there.&lt;br&gt;
Then running &lt;code&gt;bundle exec puma -C puma.rb&lt;/code&gt; will prompt something like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

➜  ~ bundle exec puma -C puma.rb
[97] Puma starting in cluster mode...
[97] * Version 4.1.0 (ruby 2.3.8-p459), codename: Fourth and One
[97] * Min threads: 5, max threads: 5
[97] * Environment: development
[97] * Process workers: 2
[97] * Phased restart available
[97] * Listening on tcp://0.0.0.0:3001
[97] * Listening on ssl://0.0.0.0:3000?cert=config/local-certs/localhost.pem&amp;amp;key=config/local-certs/localhost-key.pem&amp;amp;verify_mode=none&amp;amp;no_tlsv1=false&amp;amp;no_tlsv1_1=false
[97] Use Ctrl-C to stop
[97] - Worker 0 (pid: 105) booted, phase: 0
[97] - Worker 1 (pid: 108) booted, phase: 0


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And if you go to &lt;a href="https://localhost:3000" rel="noopener noreferrer"&gt;https://localhost:3000&lt;/a&gt;, you will see something like this🤘&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2A_7G3Hr8lRff0S0p3a-XRSQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2A_7G3Hr8lRff0S0p3a-XRSQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;SSL on localshot:3000&lt;/p&gt;

&lt;p&gt;Hope it helps you to sort out the Chrome update, ping me here or follow me on &lt;a href="https://twitter.com/MarianoMatayosh" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;, &lt;a href="https://stackoverflow.com/users/1798644/matayoshimariano" rel="noopener noreferrer"&gt;StackOverflow&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/marianomatayoshi/?locale=en_US" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://github.com/MatayoshiMariano" rel="noopener noreferrer"&gt;Github&lt;/a&gt; :)&lt;/p&gt;

&lt;p&gt;Mariano Matayoshi (&lt;a href="mailto:matayoshi.mariano@gmail.com"&gt;matayoshi.mariano@gmail.com&lt;/a&gt;)&lt;/p&gt;

</description>
      <category>rails</category>
      <category>puma</category>
      <category>ssl</category>
      <category>cookies</category>
    </item>
  </channel>
</rss>
