---
slug: "phpの-zend_http_client-で-tls12-接続する"
title: "Connecting with TLS1.2 using Zend_Http_Client in PHP"
description: "$client = new Zend_Http_Client($url);$response = $client-&gt;request('GET');\nI was doing it like this, but due to an issue with the OS, I couldn't connect using TLS 1.2."
url: "https://www.ytyng.com/en/blog/phpの-zend_http_client-で-tls12-接続する"
publish_date: "2017-12-21T09:39:24Z"
created: "2017-12-21T09:39:24Z"
updated: "2026-02-27T11:49:57.499Z"
categories: []
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/06f8518376c74517bd98ed1473331544.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Connecting with TLS1.2 using Zend_Http_Client in PHP

<pre><span>$client = new Zend_Http_Client($url);<br /></span><span>$response = $client-&gt;request('GET');</span></pre>
<p><span>I was doing it like this, but due to an issue with the OS, I couldn't connect using TLS 1.2.</span></p>
<p></p>
<p>It worked well when I switched to using the CURL adapter.</p>
<pre><span>$config = array(</span><br /><span>&nbsp; &nbsp;'adapter' &nbsp; &nbsp; &nbsp;=&gt; 'Zend_Http_Client_Adapter_Curl',</span><br /><span>&nbsp; &nbsp;'curloptions' &nbsp;=&gt; array(CURLOPT_SSLVERSION =&gt; 6),</span><br /><span>);</span><br /><span>$client = new Zend_Http_Client($url, $config);</span></pre>
<p><span></span></p>
<p>* <span><code>CURLOPT_SSLVERSION =&gt; 6</code> stands for <strong>TLS1.2</strong>. If it's <code>5</code>, it means <strong>1.1</strong>.</span></p>
<p><span></span></p>
<p><span><a href="https://www.howsmyssl.com/a/check">https://www.howsmyssl.com/a/check</a><a rel="nofollow noreferrer" target="_blank" href="https://www.google.com/url?q=https%3A%2F%2Fwww.howsmyssl.com%2Fa%2Fcheck&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNEaEIVvyrEytyJrmAAAc2NauEL_Sg" class="Xx" dir="ltr" data-display="https://www.howsmyssl.com/a/check" data-sanitized="https://www.google.com/url?q=https%3A%2F%2Fwww.howsmyssl.com%2Fa%2Fcheck&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNEaEIVvyrEytyJrmAAAc2NauEL_Sg" tabindex="-1"></a></span></p>
<p><span>This site is very useful for checking encryption protocols.</span></p>
<p><br /><span></span></p>
<p><span>Use of undefined constant CURL_SSLVERSION_TLSv1_2 &middot; Issue #26 &middot; wepay/PHP-SDK<br /><a href="https://github.com/wepay/PHP-SDK/issues/26">https://github.com/wepay/PHP-SDK/issues/26</a></span></p>
<p><span>This page was very helpful.</span></p>
