<?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: Thiago Arrais</title>
    <description>The latest articles on DEV Community by Thiago Arrais (@thiagoarrais).</description>
    <link>https://dev.to/thiagoarrais</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%2F48520%2Fc314a9bd-861c-480c-8aa1-aa05db6d0cb4.jpg</url>
      <title>DEV Community: Thiago Arrais</title>
      <link>https://dev.to/thiagoarrais</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thiagoarrais"/>
    <language>en</language>
    <item>
      <title>Storing your Terraform state in Ceph (2023)</title>
      <dc:creator>Thiago Arrais</dc:creator>
      <pubDate>Fri, 10 Nov 2023 20:47:41 +0000</pubDate>
      <link>https://dev.to/thiagoarrais/storing-your-terraform-state-in-ceph-1p1f</link>
      <guid>https://dev.to/thiagoarrais/storing-your-terraform-state-in-ceph-1p1f</guid>
      <description>&lt;p&gt;&lt;em&gt;This works with Terraform 1.6 and beyond. If you're using 1.5.x or earlier, try my &lt;a href="https://dev.to/thiagoarrais/storing-your-terraform-state-in-ceph-1lg3"&gt;older post on this matter&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you've got access to a Ceph instance, you can use the S3 backend to store the Terraform state.  The usage is pretty much the same as for S3 itself, we just need to make sure to set the following arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;endpoints.s3&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;skip_credentials_validation&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;skip_region_validation&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;skip_requesting_account_id&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;skip_s3_checksum&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;use_path_style&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;endpoints.s3&lt;/code&gt; should be set to the root URL served by your Ceph instance.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;skip_credentials_validation&lt;/code&gt; controls whether the backend validates credentials against Amazon STS. Since you can't count on STS to validate your Ceph credentials, this should be set to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;skip_region_validation&lt;/code&gt; should be set because Ceph doesn't actually use the provided region name and can't validate it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;skip_requesting_account_id&lt;/code&gt; should be set because Ceph doesn't provide the needed IAM API. It instead authenticates you using access and secret keys.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;skip_s3_checksum&lt;/code&gt; should be set because Ceph does not include the checksum in its validation. If Terraform tries to write state to Ceph while this isn't in place, you'll get a &lt;code&gt;XAmzContentSHA256Mismatch&lt;/code&gt; error.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;use_path_style&lt;/code&gt; controls if bucket names are specified in subdomains (e.g. &lt;code&gt;mybucket.myceph.myintranet&lt;/code&gt;) or in paths (e.g. &lt;code&gt;myceph.myintranet/mybucket&lt;/code&gt;). The path style is more compatible with Ceph, so this also should be set to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is a copy-and-paste friendly version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;terraform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;required_version&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&amp;gt;= 1.6.0"&lt;/span&gt;

  &lt;span class="nx"&gt;backend&lt;/span&gt; &lt;span class="s2"&gt;"s3"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;bucket&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-bucket-name"&lt;/span&gt;
    &lt;span class="nx"&gt;key&lt;/span&gt;         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"a-key"&lt;/span&gt;
    &lt;span class="nx"&gt;region&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-east-1"&lt;/span&gt;
    &lt;span class="nx"&gt;access_key&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-access-key"&lt;/span&gt;
    &lt;span class="nx"&gt;secret_key&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-secret-key"&lt;/span&gt;

    &lt;span class="nx"&gt;skip_credentials_validation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="nx"&gt;skip_region_validation&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="nx"&gt;skip_requesting_account_id&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="nx"&gt;skip_s3_checksum&lt;/span&gt;            &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="nx"&gt;use_path_style&lt;/span&gt;              &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

    &lt;span class="nx"&gt;endpoints&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;s3&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://hostname.for.the.ceph.instance"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to check if a server will accept your client certificate</title>
      <dc:creator>Thiago Arrais</dc:creator>
      <pubDate>Sun, 15 Aug 2021 20:54:02 +0000</pubDate>
      <link>https://dev.to/thiagoarrais/how-to-check-if-a-server-will-accept-your-client-certificate-2f67</link>
      <guid>https://dev.to/thiagoarrais/how-to-check-if-a-server-will-accept-your-client-certificate-2f67</guid>
      <description>&lt;p&gt;A currently fading but still very common way to authenticate client applications to serving applications is to use TLS/SSL client certificates. That way you can take advantage of the existing HTTPS infrastructure and just check the client serial number against a known list of authorized applications.&lt;/p&gt;

&lt;p&gt;This is very commonly done in an enterprise setting where the certificate issuing process can be delegated to a third party. But this also means that the internal Certificate Authority may not be readily trusted by the server application infrastructure.&lt;/p&gt;

&lt;p&gt;When that happens, the client may not be 100% sure that the server will trust its certificate. When it comes time to renew client certificates — and maybe even authorities — anxiety invariably kicks in!&lt;/p&gt;

&lt;h1&gt;
  
  
  Here's what you'll need
&lt;/h1&gt;

&lt;p&gt;OpenSSL got you covered, of course. But OpenSSL is no easy beast to deal with.&lt;/p&gt;

&lt;p&gt;The command you're looking for is &lt;code&gt;openssl verify&lt;/code&gt;. It takes as input a certificate authority list, which comes from the server application team, and a client certificate, which comes from the client application team.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy6r8tyo4f761fvnw8d9h.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy6r8tyo4f761fvnw8d9h.png" alt="Diagram of two teams, one named server team and the other named client team, providing an authority file and a certificate file respectively to the openssl verify command that spits a green check mark"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With both of those files in hand, here is what you'll need to say in your trusty shell:&lt;/p&gt;

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

$ openssl verify \
    -no-CApath \
    -CAfile certificate_authority_list.pem \
    client_certificate.pem


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

&lt;/div&gt;

&lt;p&gt;Do not forget to include the &lt;code&gt;-noCApath&lt;/code&gt; flag or else OpenSSL will use your computer's trust store &lt;em&gt;in addition&lt;/em&gt; to the given certificate authority list. You will not get an accurate picture that way. Especially if the certificate was signed by a publically trusted authority.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Sidenote about file formats:&lt;/strong&gt; We're assuming all the time that files are in PEM format. PEM files are those that include &lt;code&gt;-----BEGIN CERTIFICATE-----&lt;/code&gt; and &lt;code&gt;-----END CERTIFICATE-----&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In opensslish a green mark looks like this:&lt;/p&gt;

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

client_certificate.pem: OK


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

&lt;/div&gt;

&lt;p&gt;If you get anything like that, you're good to go!&lt;/p&gt;

&lt;h1&gt;
  
  
  What if my client certificate fails the test?
&lt;/h1&gt;

&lt;p&gt;When running &lt;code&gt;openssl verify&lt;/code&gt;, you may get an error output:&lt;/p&gt;

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

C = BE, O = GlobalSign nv-sa, CN = GlobalSign RSA OV SSL CA 2018
error 2 at 1 depth lookup: unable to get issuer certificate
error client_certificate.pem: verification failed


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

&lt;/div&gt;

&lt;p&gt;Assuming that you've got a good certificate file, any error means problems in the certificate authority file. This one shown here means that the first-level certificate authority (CA) is trusted, but the second one is not. OpenSSL starts counting at zero, "error X at 1 depth lookup" means that the 0 depth lookup was successful and there was an error at the next lookup.&lt;/p&gt;

&lt;p&gt;You'll need a clean path to a root CA from the client certificate. In other words, the client certificate needs to be signed by a trusted authority and that authority's certificate &lt;em&gt;also&lt;/em&gt; needs to be signed by a trusted authority. And so on until you get to a certificate that is signed by itself. Those are called root CAs.&lt;/p&gt;

&lt;p&gt;In order to check what CA signs your certificate, you can use another OpenSSL command:&lt;/p&gt;

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

$ openssl x509 -in client_certificate.pem -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            ...
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = BE, O = GlobalSign nv-sa, CN = GlobalSign RSA OV SSL CA 2018
        ...
        X509v3 extensions:
            Authority Information Access: 
                CA Issuers - URI:http://secure.globalsign.com/cacert/gsrsaovsslca2018.crt
                OCSP - URI:http://ocsp.globalsign.com/gsrsaovsslca2018
            X509v3 Authority Key Identifier: 
                keyid:F8:EF:7F:F2:CD:78:67:A8:DE:6F:8F:24:8D:88:F1:87:03:02:B3:EB
            ...


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

&lt;/div&gt;

&lt;p&gt;And then again with the CA certificate:&lt;/p&gt;

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

$ openssl x509 -in gsrsaovsslca2018.pem -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            01:ee:5f:22:1d:fc:62:3b:d4:33:3a:85:57
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: OU = GlobalSign Root CA - R3, O = GlobalSign, CN = GlobalSign
        Subject: C = BE, O = GlobalSign nv-sa, CN = GlobalSign RSA OV SSL CA 2018
        ...
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                F8:EF:7F:F2:CD:78:67:A8:DE:6F:8F:24:8D:88:F1:87:03:02:B3:EB
            X509v3 Authority Key Identifier: 
                keyid:8F:F0:4B:7F:A8:2E:45:24:AE:4D:50:FA:63:9A:8B:DE:E2:DD:1B:BC
            ...


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

&lt;/div&gt;

&lt;p&gt;Fortunately, this is a two-CA chain. And we just need one other check:&lt;/p&gt;

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

$ openssl x509 -in Root-R3.pem -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            04:00:00:00:00:01:21:58:53:08:a2
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: OU = GlobalSign Root CA - R3, O = GlobalSign, CN = GlobalSign
        Subject: OU = GlobalSign Root CA - R3, O = GlobalSign, CN = GlobalSign
        ...
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                8F:F0:4B:7F:A8:2E:45:24:AE:4D:50:FA:63:9A:8B:DE:E2:DD:1B:BC
        ...


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

&lt;/div&gt;

&lt;p&gt;See how the &lt;code&gt;X509v3 Authority Key Identifier&lt;/code&gt; field in one certificate corresponds to the &lt;code&gt;X509v3 Subject Key Identifier&lt;/code&gt; in the next? And that the &lt;code&gt;Issuer&lt;/code&gt; and &lt;code&gt;Subject&lt;/code&gt; in the last one are the same? This means that our certificate chain is whole.&lt;/p&gt;

&lt;p&gt;If you're lucky, the CA will provide a certificate chain file. This file includes all the CA certificates down to the root. If you're not, you may need to stitch CA files together:&lt;/p&gt;

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

$ cat gsrsaovsslca2018.pem Root-R3.pem &amp;gt; new_certificate_authority_list.pem


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

&lt;/div&gt;

&lt;p&gt;Test it again using &lt;code&gt;openssl verify&lt;/code&gt; (just in case), ask the server team to update their file and happy SSLing!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>security</category>
      <category>crypthography</category>
      <category>certificate</category>
    </item>
    <item>
      <title>Armazenando state Terraform no Ceph</title>
      <dc:creator>Thiago Arrais</dc:creator>
      <pubDate>Thu, 27 May 2021 19:30:26 +0000</pubDate>
      <link>https://dev.to/serpro/armazenando-state-terraform-no-ceph-5c7a</link>
      <guid>https://dev.to/serpro/armazenando-state-terraform-no-ceph-5c7a</guid>
      <description>&lt;p&gt;Quem tem acesso a uma instância Ceph, pode usar o backend S3 para armazenar o state Terraform. A forma de uso é basicamente a mesma que a do próprio S3. Só precisamos lembrar de configurar os seguintes argumentos:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;endpoint&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;skip_credentials_validation&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;force_path_style&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;endpoint&lt;/code&gt; deve ser o nome do host que responde pela sua instância Ceph.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;skip_credentials_validation&lt;/code&gt; controla se o backend valida credenciais contra o Amazon STS. Como você não vai conseguir que o STS valide suas credencias Ceph, vai precisar ser configurado para &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;force_path_style&lt;/code&gt; controla se o nome do bucket é especificado como subdomínio (&lt;code&gt;meubucket.meuceph.minhaintra&lt;/code&gt;, por exemplo) ou como path (&lt;code&gt;meuceph.minhaintra/meubucket&lt;/code&gt;, por exemplo). O estilo path é mais compatível com o Ceph, por isso este argumento também deve ser configurado para &lt;code&gt;true&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Aqui está uma versão para facilitar o copia-e-cola:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;terraform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;backend&lt;/span&gt; &lt;span class="s2"&gt;"s3"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;bucket&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-bucket-name"&lt;/span&gt;
    &lt;span class="nx"&gt;key&lt;/span&gt;         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"a-key"&lt;/span&gt;
    &lt;span class="nx"&gt;region&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-east-1"&lt;/span&gt;
    &lt;span class="nx"&gt;endpoint&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hostname.for.the.ceph.instance"&lt;/span&gt;
    &lt;span class="nx"&gt;access_key&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-access-key"&lt;/span&gt;
    &lt;span class="nx"&gt;secret_key&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-secret-key"&lt;/span&gt;

    &lt;span class="nx"&gt;skip_credentials_validation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="nx"&gt;force_path_style&lt;/span&gt;            &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Storing your Terraform state in Ceph (2021)</title>
      <dc:creator>Thiago Arrais</dc:creator>
      <pubDate>Thu, 27 May 2021 18:53:08 +0000</pubDate>
      <link>https://dev.to/thiagoarrais/storing-your-terraform-state-in-ceph-1lg3</link>
      <guid>https://dev.to/thiagoarrais/storing-your-terraform-state-in-ceph-1lg3</guid>
      <description>&lt;p&gt;&lt;em&gt;This works with Terraform 1.5.x and earlier. If you're using 1.6 or beyond, try my &lt;a href="https://dev.to/thiagoarrais/storing-your-terraform-state-in-ceph-1p1f"&gt;newer post on this matter&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you've got access to a Ceph instance, you can use the S3 backend to store the Terraform state.  The usage is pretty much the same as for S3 itself, we just need to make sure to set the following arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;endpoint&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;skip_credentials_validation&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;force_path_style&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;endpoint&lt;/code&gt; should be set to the hostname where your Ceph instance responds.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;skip_credentials_validation&lt;/code&gt; controls if the backend validates credentials against Amazon STS. Since you can't count on STS to validate your Ceph credentials, this should be set to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;force_path_style&lt;/code&gt; controls if bucket names are specified in subdomains (e.g. &lt;code&gt;mybucket.myceph.myintranet&lt;/code&gt;) or in paths (e.g. &lt;code&gt;myceph.myintranet/mybucket&lt;/code&gt;). The path style is more compatible with Ceph, so this also should be set to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is a copy-and-paste friendly version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;terraform&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;backend&lt;/span&gt; &lt;span class="s2"&gt;"s3"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;bucket&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-bucket-name"&lt;/span&gt;
    &lt;span class="nx"&gt;key&lt;/span&gt;         &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"a-key"&lt;/span&gt;
    &lt;span class="nx"&gt;region&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-east-1"&lt;/span&gt;
    &lt;span class="nx"&gt;endpoint&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"hostname.for.the.ceph.instance"&lt;/span&gt;
    &lt;span class="nx"&gt;access_key&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-access-key"&lt;/span&gt;
    &lt;span class="nx"&gt;secret_key&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-secret-key"&lt;/span&gt;

    &lt;span class="nx"&gt;skip_credentials_validation&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="nx"&gt;force_path_style&lt;/span&gt;            &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Como verificar se um servidor vai aceitar seu certificado de cliente</title>
      <dc:creator>Thiago Arrais</dc:creator>
      <pubDate>Thu, 01 Oct 2020 19:02:35 +0000</pubDate>
      <link>https://dev.to/serpro/como-verificar-se-um-servidor-vai-aceitar-seu-certificado-de-cliente-1omb</link>
      <guid>https://dev.to/serpro/como-verificar-se-um-servidor-vai-aceitar-seu-certificado-de-cliente-1omb</guid>
      <description>&lt;p&gt;Uma forma de autenticar aplicações clientes para aplicações servidoras que está desaparecendo mas ainda é bastante comum é o uso de certificados TLS/SSL de cliente. Desse modo você pode fazer uso da infra-estrutura HTTPS existente e apenas verificar o número de série do certificado do cliente contra uma lista conhecida de aplicações autorizadas.&lt;/p&gt;

&lt;p&gt;Isso é comumente feito em um contexto corporativo onde o processo de emissão de certificados pode ser delegado para um terceiro. Mas isso também significa que a Autoridade Certificadora pode não ser imediatamente aceita pela infra-estrutura da aplicação servidora.&lt;/p&gt;

&lt;p&gt;Quando isso acontece, talvez o cliente não tenha 100% de certeza de que o servidor vai aceitar seu certificado. Na hora de renovar certificados — e talvez até seja necessário trocar de autoridade — a ansiedade invariavelmente ataca!&lt;/p&gt;

&lt;h1&gt;
  
  
  Faça isso então
&lt;/h1&gt;

&lt;p&gt;O OpenSSL vai te ajudar, claro. Mas o OpenSSL não é exatamente fácil de lidar.&lt;/p&gt;

&lt;p&gt;O comando que você precisa é &lt;code&gt;openssl verify&lt;/code&gt;. Ele recebe como entrada uma lista de autoridades certificadoras, que vem da equipe da aplicação servidora, e um certificado de cliente, que vem da equipe da aplicação cliente.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CTH3cObC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y6r8tyo4f761fvnw8d9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CTH3cObC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y6r8tyo4f761fvnw8d9h.png" alt="Diagrama de duas equipes, uma equipe do servidor e a outra do cliente, fornecendo um arquivo de autoridades e um arquivo de certificado respectivamente para o comando openssl verify que cospe uma marca de sucesso verde"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Com esses dois arquivos em mãos, aqui está o que você vai precisar dizer no seu shell preferido:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ openssl verify \
    -no-CApath \
    -CAfile certificate_authority_list.pem \
    client_certificate.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Não esqueça de incluir a flag &lt;code&gt;-noCApath&lt;/code&gt; ou então o OpenSSL vai usar a trust store do computador &lt;em&gt;além&lt;/em&gt; da lista de autoridades certificadores fornecida. Você não vai conseguir uma resposta precisa assim. Especialmente se o certificado foi assinado por uma autoridade publicamente reconhecida.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Nota de rodapé sobre formatos de arquivo:&lt;/strong&gt; Estamos o tempo todo assumindo que os arquivos estão em formato PEM. Arquivos PEM são aqueles que contém linhas &lt;code&gt;-----BEGIN CERTIFICATE-----&lt;/code&gt; e &lt;code&gt;-----END CERTIFICATE-----&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Em openssl-ês uma marca verde de sucesso tem essa cara:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client_certificate.pem: OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Se você receber algo parecido com isso, pode parar por aqui que já está tudo certo!&lt;/p&gt;

&lt;h1&gt;
  
  
  E se meu certificado de cliente não passar no teste?
&lt;/h1&gt;

&lt;p&gt;Ao rodar o &lt;code&gt;openssl verify&lt;/code&gt;, você pode tomar um erro:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C = BE, O = GlobalSign nv-sa, CN = GlobalSign RSA OV SSL CA 2018
error 2 at 1 depth lookup: unable to get issuer certificate
error client_certificate.pem: verification failed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assumindo que está tudo certo com seu arquivo de certificado, qualquer erro significa problema no arquivo das autoridades certificadoras. Este que foi mostrado aqui significa que a autoridade certificadora (AC) de primeiro nível é confiável, mas a de segundo nível não. O OpenSSL inicia a contagem de zero, "error X at 1 depth lookup" significa que a busca &lt;em&gt;depth 0&lt;/em&gt; foi bem sucedida e houve um erro na busca seguinte.&lt;/p&gt;

&lt;p&gt;Vamos precisar de um caminho limpo até uma AC raiz a partir do certificado do cliente. Em outras palavras, o certificado de cliente precisa ser assinado por uma autoridade confiável e o certificado dessa autoridade _também precisa ser assinado por uma autoridade confiável. E assim por adiante até chegarmos em um certificado que está assinado por si mesmo. Estas são as ACs raiz.&lt;/p&gt;

&lt;p&gt;Para verificar que AC assina o certificado, você pode usar outro commando OpenSSL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ openssl x509 -in client_certificate.pem -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            ...
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = BE, O = GlobalSign nv-sa, CN = GlobalSign RSA OV SSL CA 2018
        ...
        X509v3 extensions:
            Authority Information Access: 
                CA Issuers - URI:http://secure.globalsign.com/cacert/gsrsaovsslca2018.crt
                OCSP - URI:http://ocsp.globalsign.com/gsrsaovsslca2018
            X509v3 Authority Key Identifier: 
                keyid:F8:EF:7F:F2:CD:78:67:A8:DE:6F:8F:24:8D:88:F1:87:03:02:B3:EB
            ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;E novamente com o certificado da AC:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ openssl x509 -in gsrsaovsslca2018.pem -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            01:ee:5f:22:1d:fc:62:3b:d4:33:3a:85:57
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: OU = GlobalSign Root CA - R3, O = GlobalSign, CN = GlobalSign
        Subject: C = BE, O = GlobalSign nv-sa, CN = GlobalSign RSA OV SSL CA 2018
        ...
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                F8:EF:7F:F2:CD:78:67:A8:DE:6F:8F:24:8D:88:F1:87:03:02:B3:EB
            X509v3 Authority Key Identifier: 
                keyid:8F:F0:4B:7F:A8:2E:45:24:AE:4D:50:FA:63:9A:8B:DE:E2:DD:1B:BC
            ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Felizmente, essa é uma cadeia com apenas duas AC. Só precisamos de mais uma verificação:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ openssl x509 -in Root-R3.pem -text
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            04:00:00:00:00:01:21:58:53:08:a2
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: OU = GlobalSign Root CA - R3, O = GlobalSign, CN = GlobalSign
        Subject: OU = GlobalSign Root CA - R3, O = GlobalSign, CN = GlobalSign
        ...
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                8F:F0:4B:7F:A8:2E:45:24:AE:4D:50:FA:63:9A:8B:DE:E2:DD:1B:BC
        ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Está vendo como o campo &lt;code&gt;X509v3 Authority Key Identifier&lt;/code&gt; em um certificado corresponde ao campo &lt;code&gt;X509v3 Subject Key Identifier&lt;/code&gt; do certificado seguinte? E que o &lt;code&gt;Issuer&lt;/code&gt; e o &lt;code&gt;Subject&lt;/code&gt; no último são os mesmos? Isso significa que nossa cadeia de certificados está íntegra.&lt;/p&gt;

&lt;p&gt;Se você tiver sorte, a autoridade certificadora em si vai prover um arquivo de cadeia de certificados em seu site. Esse arquivo inclui todos os certificados de AC até o raiz. Se não, você vai precisar costurar arquivos de AC:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cat gsrsaovsslca2018.pem Root-R3.pem &amp;gt; new_certificate_authority_list.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Teste esse arquivo novo usando o &lt;code&gt;openssl verify&lt;/code&gt; (só por precaução), peça à equipe do servidor para atualizar seu arquivo de autoridades e boa viagem com SSL!&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>security</category>
      <category>crypthography</category>
      <category>certificate</category>
    </item>
  </channel>
</rss>
