Skip to content

Instantly share code, notes, and snippets.

@hfm
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save hfm/11324355 to your computer and use it in GitHub Desktop.

Select an option

Save hfm/11324355 to your computer and use it in GitHub Desktop.

問題

raw.github.comがraw.githubusercontent.comにリダイレクトされるようになって、CentOS 6.5等でcurlがコケるようになってしまった。

(os xだと問題なく動いた)

$ cat /etc/redhat-release
CentOS release 6.5 (Final)
$ curl -vIL http://cpanmin.us
* About to connect() to cpanmin.us port 80 (#0)
*   Trying 202.181.96.213... connected
* Connected to cpanmin.us (202.181.96.213) port 80 (#0)
> HEAD / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: cpanmin.us
> Accept: */*
>
< HTTP/1.1 302 Found
HTTP/1.1 302 Found
< Server: nginx/1.2.7
Server: nginx/1.2.7
< Date: Sat, 26 Apr 2014 16:30:43 GMT
Date: Sat, 26 Apr 2014 16:30:43 GMT
< Content-Type: text/html; charset=iso-8859-1
Content-Type: text/html; charset=iso-8859-1
< Connection: keep-alive
Connection: keep-alive
< Location: https://raw.github.com/miyagawa/cpanminus/master/cpanm
Location: https://raw.github.com/miyagawa/cpanminus/master/cpanm
* no chunk, no close, no size. Assume close to signal end

<
* Closing connection #0
* Issue another request to this URL: 'https://raw.github.com/miyagawa/cpanminus/master/cpanm'
* About to connect() to raw.github.com port 443 (#0)
*   Trying 103.245.222.133... connected
* Connected to raw.github.com (103.245.222.133) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using SSL_RSA_WITH_RC4_128_SHA
* Server certificate:
* 	subject: CN=www.github.com,O="Fastly, Inc.",L=San Francisco,ST=California,C=US
* 	start date:  2月 25 00:00:00 2014 GMT
* 	expire date:  3月 02 12:00:00 2015 GMT
* 	common name: www.github.com
* 	issuer: CN=DigiCert High Assurance CA-3,OU=www.digicert.com,O=DigiCert Inc,C=US
> HEAD /miyagawa/cpanminus/master/cpanm HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: raw.github.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
HTTP/1.1 301 Moved Permanently
< Date: Sat, 26 Apr 2014 16:30:43 GMT
Date: Sat, 26 Apr 2014 16:30:43 GMT
< Server: Apache
Server: Apache
< Location: https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm
Location: https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Via: 1.1 varnish
Via: 1.1 varnish
< Age: 0
Age: 0
< X-Served-By: cache-ty67-TYO
X-Served-By: cache-ty67-TYO
< X-Cache: MISS
X-Cache: MISS
< X-Cache-Hits: 0
X-Cache-Hits: 0
< Vary: Accept-Encoding
Vary: Accept-Encoding
* no chunk, no close, no size. Assume close to signal end

<
* Closing connection #0
* Issue another request to this URL: 'https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm'
* About to connect() to raw.githubusercontent.com port 443 (#0)
*   Trying 103.245.222.133... connected
* Connected to raw.githubusercontent.com (103.245.222.133) port 443 (#0)
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using SSL_RSA_WITH_RC4_128_SHA
* Server certificate:
* 	subject: CN=www.github.com,O="Fastly, Inc.",L=San Francisco,ST=California,C=US
* 	start date:  2月 25 00:00:00 2014 GMT
* 	expire date:  3月 02 12:00:00 2015 GMT
* 	common name: www.github.com
* 	issuer: CN=DigiCert High Assurance CA-3,OU=www.digicert.com,O=DigiCert Inc,C=US
> HEAD /miyagawa/cpanminus/master/cpanm HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: raw.githubusercontent.com
> Accept: */*
>
< HTTP/1.1 400 Bad Request
HTTP/1.1 400 Bad Request
< Date: Sat, 26 Apr 2014 16:30:43 GMT
Date: Sat, 26 Apr 2014 16:30:43 GMT
< Server: Apache
Server: Apache
< Connection: close
Connection: close
< Content-Type: text/html; charset=iso-8859-1
Content-Type: text/html; charset=iso-8859-1

<
* Closing connection #0

解決

curl 7.19.7から7.36.0にバージョンあげたら上手く動いた。

$ sudo rpm -Uvh http://mirror.city-fan.org/ftp/contrib/sysutils/Mirroring/curl-7.36.0-3.0.cf.rhel6.x86_64.rpm \ 
http://mirror.city-fan.org/ftp/contrib/sysutils/Mirroring/libcurl-7.36.0-3.0.cf.rhel6.x86_64.rpm \  
http://mirror.city-fan.org/ftp/contrib/sysutils/Mirroring/libcurl7155-7.15.5-17.cf.rhel6.x86_64.rpm \ 
http://mirror.city-fan.org/ftp/contrib/libraries/libssh2-1.4.3-11.0.cf.rhel6.x86_64.rpm \ 
http://mirror.city-fan.org/ftp/contrib/libraries/libmetalink-0.1.2-4.rhel6.x86_64.rpm \ 
http://mirror.city-fan.org/ftp/contrib/libraries/c-ares-1.10.0-2.0.cf.rhel6.x86_64.rpm

curlと依存関係にあるツールのアップデート後のcurl

$ curl -vIL http://cpanmin.us
* Rebuilt URL to: http://cpanmin.us/
* Hostname was NOT found in DNS cache
*   Trying 202.181.96.213...
* Connected to cpanmin.us (202.181.96.213) port 80 (#0)
> HEAD / HTTP/1.1
> User-Agent: curl/7.36.0
> Host: cpanmin.us
> Accept: */*
>
< HTTP/1.1 302 Found
HTTP/1.1 302 Found
* Server nginx/1.2.7 is not blacklisted
< Server: nginx/1.2.7
Server: nginx/1.2.7
< Date: Sat, 26 Apr 2014 16:37:35 GMT
Date: Sat, 26 Apr 2014 16:37:35 GMT
< Content-Type: text/html; charset=iso-8859-1
Content-Type: text/html; charset=iso-8859-1
< Connection: keep-alive
Connection: keep-alive
< Location: https://raw.github.com/miyagawa/cpanminus/master/cpanm
Location: https://raw.github.com/miyagawa/cpanminus/master/cpanm

<
* Connection #0 to host cpanmin.us left intact
* Issue another request to this URL: 'https://raw.github.com/miyagawa/cpanminus/master/cpanm'
* Hostname was NOT found in DNS cache
*   Trying 103.245.222.133...
* Connected to raw.github.com (103.245.222.133) port 443 (#1)
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* Server certificate:
*        subject: C=US; ST=California; L=San Francisco; O=Fastly, Inc.; CN=www.github.com
*        start date: 2014-02-25 00:00:00 GMT
*        expire date: 2015-03-02 12:00:00 GMT
*        subjectAltName: raw.github.com matched
*        issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Assurance CA-3
*        SSL certificate verify ok.
> HEAD /miyagawa/cpanminus/master/cpanm HTTP/1.1
> User-Agent: curl/7.36.0
> Host: raw.github.com
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
HTTP/1.1 301 Moved Permanently
< Date: Sat, 26 Apr 2014 16:37:35 GMT
Date: Sat, 26 Apr 2014 16:37:35 GMT
* Server Apache is not blacklisted
< Server: Apache
Server: Apache
< Location: https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm
Location: https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Via: 1.1 varnish
Via: 1.1 varnish
< Age: 0
Age: 0
< X-Served-By: cache-ty68-TYO
X-Served-By: cache-ty68-TYO
< X-Cache: MISS
X-Cache: MISS
< X-Cache-Hits: 0
X-Cache-Hits: 0
< Vary: Accept-Encoding
Vary: Accept-Encoding

<
* Connection #1 to host raw.github.com left intact
* Issue another request to this URL: 'https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm'
* Hostname was NOT found in DNS cache
*   Trying 103.245.222.133...
* Connected to raw.githubusercontent.com (103.245.222.133) port 443 (#2)
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* Server certificate:
*        subject: C=US; ST=California; L=San Francisco; O=Fastly, Inc.; CN=www.github.com
*        start date: 2014-02-25 00:00:00 GMT
*        expire date: 2015-03-02 12:00:00 GMT
*        subjectAltName: raw.githubusercontent.com matched
*        issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Assurance CA-3
*        SSL certificate verify ok.
> HEAD /miyagawa/cpanminus/master/cpanm HTTP/1.1
> User-Agent: curl/7.36.0
> Host: raw.githubusercontent.com
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Sat, 26 Apr 2014 16:37:35 GMT
Date: Sat, 26 Apr 2014 16:37:35 GMT
* Server Apache is not blacklisted
< Server: Apache
Server: Apache
< Content-Security-Policy: default-src 'none'
Content-Security-Policy: default-src 'none'
< Access-Control-Allow-Origin: https://render.githubusercontent.com
Access-Control-Allow-Origin: https://render.githubusercontent.com
< X-XSS-Protection: 1; mode=block
X-XSS-Protection: 1; mode=block
< X-Frame-Options: deny
X-Frame-Options: deny
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< Strict-Transport-Security: max-age=31536000
Strict-Transport-Security: max-age=31536000
< ETag: "954aae1bfa70fa56f903030f380eaa938130472c"
ETag: "954aae1bfa70fa56f903030f380eaa938130472c"
< Content-Type: text/plain; charset=utf-8
Content-Type: text/plain; charset=utf-8
< Cache-Control: max-age=300
Cache-Control: max-age=300
< Content-Length: 268417
Content-Length: 268417
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Via: 1.1 varnish
Via: 1.1 varnish
< X-Served-By: cache-ty66-TYO
X-Served-By: cache-ty66-TYO
< X-Cache: MISS
X-Cache: MISS
< X-Cache-Hits: 0
X-Cache-Hits: 0
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Expires: Sat, 26 Apr 2014 16:42:35 GMT
Expires: Sat, 26 Apr 2014 16:42:35 GMT
< Source-Age: 0
Source-Age: 0

<
* Connection #2 to host raw.githubusercontent.com left intact
* ```
@hfm

hfm commented Apr 27, 2014

Copy link
Copy Markdown
Author
curl -L https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm

古いcurlであっても、リダイレクト先であるraw.githubusercontent.comを直接叩いてもokでした。
raw.github.comからraw.githubusercontent.comへのリダイレクトで死んでしまう様子。

@hfm

hfm commented Apr 27, 2014

Copy link
Copy Markdown
Author

curl 7.19.7だと、curl -1L http://cpanmin.uscurl -3L http://cpanmin.usだと上手く行きました。
デフォルトがcurl --sslv2になってるのかもしれない。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment