title: How to use ServerXMLHTTP60 and a client SSL certificate in Excel using VBA?
body: <p>I cannot get it to work in VBA - Excel. I use the same header and XML-body in Postman - fine! Good response. I need to use a client certificate to identify myself, but I cannot get it done in VBA. The code needs to post some data (the XMLPostMessage) and then it receives some data from the server (a XML message as well).</p>
  <p>The response I get from the server is a message in XML that has something to do with &quot;Unidentified user&quot;. So, I do have communication, but it is not recognised as 'from a trusted party'. But using this certificate in Postman does give a good response.</p>
  <p>== My VBA code: ==</p>
  <pre><code>Public Sub server()
  Dim O As New ServerXMLHTTP60
  Dim xmlDoc As New MSXML2.DOMDocument60
  Dim XMLPostMessage As String
  
  XMLPostMessage = &quot;&lt;WEB-UAS-AANVR&gt;&quot; &amp; _
              &quot;&lt;ALG-GEG&gt;&quot; &amp; _
                  &quot;&lt;PROC-IDENT&gt;3637&lt;/PROC-IDENT&gt;&quot; &amp; _
                  &quot;&lt;PROC-FUNC&gt;1&lt;/PROC-FUNC&gt;&quot; &amp; _
                  &quot;&lt;INFO-GEBR&gt;DITISEENTEST&lt;/INFO-GEBR&gt;&quot; &amp; _
              &quot;&lt;/ALG-GEG&gt;&quot; &amp; _
              &quot;&lt;WEB-UAS-GEG&gt;&quot; &amp; _
              &quot;&lt;UAS-VRR-EXAMEN-GEG&gt;&quot; &amp; _
                      &quot;&lt;UAS-VRR-EX-INST&gt;&lt;/UAS-VRR-EX-INST&gt;&quot; &amp; _
                      &quot;&lt;UAS-VRR-EX-SRT&gt;A2&lt;/UAS-VRR-EX-SRT&gt;&quot; &amp; _
                      &quot;&lt;UAS-VRR-EX-DAT&gt;20211210&lt;/UAS-VRR-EX-DAT&gt;&quot; &amp; _
                      &quot;&lt;GEB-DAT-UAS-VRR&gt;19840726&lt;/GEB-DAT-UAS-VRR&gt;&quot; &amp; _
                      &quot;&lt;UAS-VRR-EX-REF&gt;#12345&lt;/UAS-VRR-EX-REF&gt;&quot; &amp; _
                  &quot;&lt;/UAS-VRR-EXAMEN-GEG&gt;&quot; &amp; _
              &quot;&lt;/WEB-UAS-GEG&gt;&quot; &amp; _
          &quot;&lt;/WEB-UAS-AANVR&gt;&quot;
  
  With O
      .Open &quot;POST&quot;, &quot;https://&lt;the serverpath goes here&gt;&quot;, False
      .setRequestHeader &quot;Content-type&quot;, &quot;application/xml&quot;
      .setRequestHeader &quot;Content-type&quot;, &quot;text/xml&quot;
      .setRequestHeader &quot;Charset&quot;, &quot;UTF-8&quot;
      .setOption 3, &quot;&lt;The Friendly Name of the certificate goes here&gt;&quot;
  '    .setOption 3, &quot;CURRENT_USER\My\&lt;The Friendly Name of the certificate goes here&gt;&quot;
      
      .send XMLPostMessage
      xmlDoc.LoadXML (O.responseXML.XML)
      Debug.Print xmlDoc.XML
      
      If Not .Status = 200 Then
          MsgBox &quot;UnAuthorized. Message: &quot; &amp; .Status &amp; &quot; - &quot; &amp; .statusText
          Exit Sub
      End If
          
  End With
  
  Set O = Nothing
  
  End Sub
  </code></pre>