Demonstrações práticas de inspeção de certificados com OpenSSL, validação de cadeia de confiança e testes de handshake TLS 1.3.


🗺️ Cadeia de Confiança X.509 em Mermaid

flowchart TD
    ROOT["Root CA (Autoridade Certificadora Raiz)\n[ISRG Root X1 - Pré-instalada no Sistema Operacional] 🏛️"]
    --> |"Assina Digitalmente"| INT["Intermediate CA (Autoridade Intermediária)\n[Let's Encrypt R3] 🏢"]
    
    INT --> |"Assina Digitalmente"| LEAF["Leaf / Server Certificate (Certificado do Seu Site)\n[api.meusite.com.br] 🔒 ⚡"]

    style ROOT fill:#ede7f6,stroke:#512da8,stroke-width:1.5px
    style INT fill:#e1f5fe,stroke:#03a9f4,stroke-width:1.5px
    style LEAF fill:#00897b,stroke:#004d40,stroke-width:2px,color:#ffffff

📄 Exemplo 1: Teste de Handshake TLS 1.3 com openssl s_client

# Inspecionar o handshake TLS 1.3 completo, ciphers e cadeia de certificados:
openssl s_client -connect google.com:443 -tls1_3 -servername google.com

# Exibir a data de expiração e o emissor do certificado de um domínio:
echo | openssl s_client -servername github.com -connect github.com:443 2>/dev/null | openssl x509 -noout -dates -issuer -subject

📄 Exemplo 2: Servidor HTTPS em Node.js com Certificados Locais

const https = require('https');
const fs = require('fs');

const options = {
  key: fs.readFileSync('localhost.key'),
  cert: fs.readFileSync('localhost.crt')
};

https.createServer(options, (req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.end('Conexão TLS 1.3 Segura Estabelecida!\n');
}).listen(8443, () => {
  console.log('Servidor HTTPS rodando em https://localhost:8443');
});