Skip to content

Instantly share code, notes, and snippets.

@pedroinfo
Last active June 3, 2025 21:06
Show Gist options
  • Save pedroinfo/eff9230be58f442f492f243739705e6e to your computer and use it in GitHub Desktop.
Save pedroinfo/eff9230be58f442f492f243739705e6e to your computer and use it in GitHub Desktop.
Sub EnviarComCertificadoCliente()
Dim http As Object
Dim url As String
Dim certSubject As String
Dim json As String
url = "https://sua-api.com/endpoint"
certSubject = "CN=Nome do seu certificado"
Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
http.Open "POST", url, False
' Configura o certificado cliente pelo subject da store do usuário
' O parâmetro pode ser:
' "CURRENT_USER\MY\<subject>" ou "LOCAL_MACHINE\MY\<subject>"
' Exemplo:
http.SetClientCertificate "CURRENT_USER\MY\" & certSubject
http.SetRequestHeader "Content-Type", "application/json"
json = "{""chave"":""valor""}"
http.Send json
MsgBox "Status: " & http.Status & vbCrLf & "Resposta: " & http.ResponseText
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment