title: Sending notifications to Microsoft Teams for Jenkins. [hostname in certificate didn't match] error
body: <p>I have a problem sending the job notification at work, here I use the company's VPN and firewall. The Job runs successfully and it is possible to see in the log that the connector was activated, but the notification is not sent.
  If you use a manual curl with the message it works normal</p>
  <pre><code> script {
                      final String url = &quot;webhook&quot;
  
                      final String response = sh(script: &quot;curl -X POST -H 'Content-type:application/json' --data '{\&quot;text\&quot;:\&quot;Message sent by jenkins\&quot;}' webhook&quot;, returnStdout: true).trim()
  
                      echo response
                  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/D9Z3u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D9Z3u.png" alt="enter image description here" /></a></p>
  <p>but in an automated way by Jenkins it is not working</p>
  <p>Follow the part of the office 365 pipeline:</p>
  <pre><code>post {
        failure {
          office365ConnectorSend webhookUrl: &quot;$WEB_HOOK_URL&quot;,
                  factDefinitions: [[name: &quot;message&quot;, template: &quot;Falha: Deploy em $DEPLOY_STAGE de $REPO&quot;],
                                    [name: &quot;status&quot;, template: &quot;Falha&quot;]],
                  color: &quot;#FF0000&quot;,
                  status: &quot;Failure&quot;
  
          sh(&quot;curl -v --location --request POST '$WEB_HOOK_URL' --header 'Content-Type: application/json' --data-raw '{\&quot;@type\&quot;: \&quot;MessageCard\&quot;,\&quot;@context\&quot;: \&quot;http://schema.org/extensions\&quot;,\&quot;themeColor\&quot;: \&quot;#FF0000\&quot;,\&quot;summary\&quot;: \&quot;Teste de Mensagens EndPoint Jenkins\&quot;,\&quot;sections\&quot;: [{\&quot;activityTitle\&quot;: \&quot;Jenkins avisa!\&quot;,\&quot;activitySubtitle\&quot;: \&quot;Resultado do build\&quot;,\&quot;activityImage\&quot;: \&quot;https://ac-buckets-dev-acpublicmedia-2cxkd4j0deg1.s3.amazonaws.com/icons/RedDownArrow.png\&quot;,\&quot;facts\&quot;: [{\&quot;name\&quot;: \&quot;Message\&quot;,\&quot;value\&quot;: \&quot;FALHA: Deploy em $DEPLOY_STAGE de $REPO\&quot;}, {\&quot;name\&quot;: \&quot;Status\&quot;,\&quot;value\&quot;: \&quot;Failure\&quot;},{\&quot;name\&quot;: \&quot;Job\&quot;,\&quot;value\&quot;: \&quot;${JOB_NAME}:${BUILD_NUMBER}\&quot;}],\&quot;markdown\&quot;: true}],\&quot;potentialAction\&quot;: [{\&quot;@type\&quot;: \&quot;OpenUri\&quot;,\&quot;name\&quot;: \&quot;Abrir Build\&quot;,\&quot;targets\&quot;: [{ \&quot;os\&quot;: \&quot;default\&quot;, \&quot;uri\&quot;: \&quot;${BUILD_URL}\&quot; }]}]}'&quot;)
        }
        success {
          office365ConnectorSend webhookUrl: &quot;$WEB_HOOK_URL&quot;,
                  factDefinitions: [[name: &quot;message&quot;, template: &quot;Sucess: Deploy em $DEPLOY_STAGE de $REPO&quot;],
                                    [name: &quot;status&quot;, template: &quot;Sucesso&quot;]],
                  color: &quot;#00FF00&quot;,
                  status: &quot;Success&quot;
  
          sh(&quot;curl -v --location --request POST '$WEB_HOOK_URL' --header 'Content-Type: application/json' --data-raw '{\&quot;@type\&quot;: \&quot;MessageCard\&quot;,\&quot;@context\&quot;: \&quot;http://schema.org/extensions\&quot;,\&quot;themeColor\&quot;: \&quot;#00FF00\&quot;,\&quot;summary\&quot;: \&quot;Teste de Mensagens EndPoint Jenkins\&quot;,\&quot;sections\&quot;: [{\&quot;activityTitle\&quot;: \&quot;Jenkins avisa!\&quot;,\&quot;activitySubtitle\&quot;: \&quot;Resultado do build\&quot;,\&quot;activityImage\&quot;: \&quot;https://ac-buckets-dev-acpublicmedia-2cxkd4j0deg1.s3.amazonaws.com/icons/GreenThumbUP.png\&quot;,\&quot;facts\&quot;: [{\&quot;name\&quot;: \&quot;Message\&quot;,\&quot;value\&quot;: \&quot;Sucesso: Deploy em $DEPLOY_STAGE de $REPO\&quot;}, {\&quot;name\&quot;: \&quot;Status\&quot;,\&quot;value\&quot;: \&quot;Success\&quot;},{\&quot;name\&quot;: \&quot;Job\&quot;,\&quot;value\&quot;: \&quot;${JOB_NAME}:${BUILD_NUMBER}\&quot;}],\&quot;markdown\&quot;: true}],\&quot;potentialAction\&quot;: [{\&quot;@type\&quot;: \&quot;OpenUri\&quot;,\&quot;name\&quot;: \&quot;Abrir Build\&quot;,\&quot;targets\&quot;: [{ \&quot;os\&quot;: \&quot;default\&quot;, \&quot;uri\&quot;: \&quot;${BUILD_URL}\&quot; }]}]}'&quot;)
        }
      }
  </code></pre>
  <p>Logs:</p>
  <pre><code>[Office365connector] Failed to post data to webhook - webhook
      javax.net.ssl.SSLException: hostname in certificate didn't match: &lt;&gt; != &lt;/*.clo.footprintdns.com/*.hotmail.com/*.internal.outlook.com/*.live.com/*.nrb.footprintdns.com/*.office.com/*.office365.com/*.outlook.com/*.outlook.office365.com/attachment.outlook.live.net/attachment.outlook.office.net/attachment.outlook.officeppe.net/attachments.office.net/attachments-sdf.office.net/ccs.login.microsoftonline.com/ccs-sdf.login.microsoftonline.com/hotmail.com/mail.services.live.com/office365.com/outlook.com/outlook.office.com/substrate.office.com/substrate-sdf.office.com/outlook.com&gt;
          at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.verifyHostName(SSLProtocolSocketFactory.java:339)
          at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.verifyHostName(SSLProtocolSocketFactory.java:275)
          at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.verifyHostName(SSLProtocolSocketFactory.java:258)
          at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:167)
          at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:714)
          at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:394)
          at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:178)
          at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:404)
          at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:330)
          at jenkins.plugins.office365connector.HttpWorker.run(HttpWorker.java:83)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
          at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  <p>How can i solve this problem ?</p>