teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2018/11/17 02:59

投稿

moonphase
moonphase

スコア6621

answer CHANGED
@@ -15,4 +15,39 @@
15
15
  $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
16
16
  curl_close( $ch );
17
17
  \Log::debug("CurlTest:" . $httpCode );
18
+ ```
19
+
20
+ # 以下追記
21
+
22
+
23
+ CA証明書がないエラーが発生する場合がある時の対応
24
+ 一旦試してもらえますか?
25
+
26
+ ```
27
+ composer require composer/ca-bundle
28
+ ```
29
+
30
+ ```php
31
+ $ch = curl_init();
32
+ curl_setopt( $ch, CURLOPT_URL, "https://www.google.com" );
33
+
34
+ $caPathOrFile = \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
35
+ if (is_dir($caPathOrFile) || (is_link($caPathOrFile) && is_dir(readlink($caPathOrFile)))) {
36
+ curl_setopt($curl, CURLOPT_CAPATH, $caPathOrFile);
37
+ } else {
38
+ curl_setopt($curl, CURLOPT_CAINFO, $caPathOrFile);
39
+ }
40
+
41
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE);
42
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, FALSE);
43
+ curl_setopt( $ch, CURLOPT_TIMEOUT, 5 );
44
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
45
+ if( ! $result = curl_exec($ch)) {
46
+ \Log::debug("CurlError:" . curl_error($ch));
47
+ }
48
+
49
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
50
+ curl_close( $ch );
51
+ \Log::debug("CurlTest:" . $httpCode );
52
+
18
53
  ```