• 使用curl在命令行中下载文件


    http://m.blog.csdn.net/blog/mayadong7349/7019208

    使用curl在命令行中下载文件

    linux下curl简单应用详解

    http://blog.sina.com.cn/s/blog_4da051a60101drqv.html

    (对curl命令的使用比较齐全)

    http://blog.csdn.net/csfreebird/article/details/9237925

    用curl访问HTTPS站点并登录

    http://blog.csdn.net/sjin_1314/article/details/17392675

    linux C libcurl https 使用

     

    http://www.ichiayi.com/wiki/tech/curl_ssl

    cURL 讀取雙向 ssl 認證 Web Server 網頁方式

    CURL使用SSL证书访问HTTPS

    http://blog.chinaunix.net/uid-192452-id-3954329.html

    若服务端要求客户端认证,需要将pfx证书转换成pem格式

    openssl pkcs12 -clcerts -nokeys -in cert.pfx -out client.pem    #客户端个人证书的公钥  

    openssl pkcs12 -nocerts -nodes -in cert.pfx -out key.pem #客户端个人证书的私钥

    也可以转换为公钥与私钥合二为一的文件

    openssl pkcs12 -in  cert.pfx -out all.pem -nodes                                   #客户端公钥与私钥,一起存在all.pem中


    执行curl命令

    1、使用client.pem+key.pem

    curl -k --cert client.pem --key key.pem https://www.xxxx.com

     

    2、使用all.pem

    curl -k --cert all.pem  https://www.xxxx.com

     

    使用-k,是不对服务器的证书进行检查,这样就不必关心服务器证书的导出问题了。

     

     

     

     

     

     OpenSSL Verify return code: 20 (unable to get local issuer certificate)

    http://stackoverflow.com/questions/11548336/openssl-verify-return-code-20-unable-to-get-local-issuer-certificate

     

    yingc@yingc:~/work/public/solution$ openssl s_client -connect 74.125.128.139:443
    CONNECTED(00000003)
    depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
    verify error:num=20:unable to get local issuer certificate
    verify return:0
    ---
    Certificate chain
     0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.google.com
       i:/C=US/O=Google Inc/CN=Google Internet Authority G2
     1 s:/C=US/O=Google Inc/CN=Google Internet Authority G2
       i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
     2 s:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
       i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority

     

    SSL-Session:
        Protocol  : TLSv1.1
        Cipher    : ECDHE-RSA-RC4-SHA
        Session-ID: 867D004577B0B77EA7ACE36EBEA8234C2BE21ABBEDA4A2B17CD9BEB9CA08E5F8
        Session-ID-ctx:
        Master-Key: 8C9F4C5E01512A14D6F062DE6BDF33F2032A85215C5449055D25D52151458B5380351D0C84D42215455320E4E2EC473D
        Key-Arg   : None
        PSK identity: None
        PSK identity hint: None
        SRP username: None
        TLS session ticket lifetime hint: 100800 (seconds)
        TLS session ticket:
        0000 - 17 25 ea c9 98 a9 1d bd-35 01 ce 18 a2 87 ec ea   .%......5.......
        0010 - 29 19 21 fc 79 a3 e4 23-89 97 f2 52 88 1d d1 0c   ).!.y..#...R....
        0020 - 2f 69 4c 20 78 9c e4 73-e2 8c 71 aa fa 83 67 84   /iL x..s..q...g.
        0030 - 56 8e 1d 3b 55 03 3b ad-b5 bb 6b df 85 d1 a6 af   V..;U.;...k.....
        0040 - 19 a5 38 41 4a f9 8a 19-52 11 bd 68 e3 5b 47 15   ..8AJ...R..h.[G.
        0050 - 3a 84 52 af a4 81 db 90-82 db f2 9d 47 df 00 6f   :.R.........G..o
        0060 - c5 28 c4 ef 85 94 f0 72-fc 47 7f 38 4f 1f 48 3e   .(.....r.G.8O.H>
        0070 - 37 ba e1 0e 5c c6 62 05-62 8c 35 27 73 74 73 92   7....b.b.5'sts.
        0080 - 7a c1 a2 10 12 db b7 be-37 04 8a 56 f3 d1 58 75   z.......7..V..Xu
        0090 - df a3 ef 31                                       ...1

        Start Time: 1388745557
        Timeout   : 300 (sec)
        Verify return code: 20 (unable to get local issuer certificate)



     

     

    openssl s_client -CApath /etc/ssl/certs/ -connect 74.125.128.139:443

    Expansion: NONE
    SSL-Session:
        Protocol  : TLSv1.1
        Cipher    : ECDHE-RSA-RC4-SHA
        Session-ID: 932BBA8E505C788ABD841F8FA94E685654264E1076A723C3AF8C6967744A1936
        Session-ID-ctx:
        Master-Key: A2BA6685C97FFD38906103B6AC7CC01BE017AC4D890D41E8167B5063EA9797C6395F3E01437754B7D9FF7726156C9F55
        Key-Arg   : None
        PSK identity: None
        PSK identity hint: None
        SRP username: None
        TLS session ticket lifetime hint: 100800 (seconds)
        TLS session ticket:
        0000 - 17 25 ea c9 98 a9 1d bd-35 01 ce 18 a2 87 ec ea   .%......5.......
        0010 - 5d 6c 40 86 a9 e1 04 35-17 0c 06 ab 8d e1 9c aa   ]l@....5........
        0020 - 24 4c 13 af a0 6b fe e3-aa bf b0 38 64 67 5e 78   $L...k.....8dg^x
        0030 - aa f2 08 b2 74 06 ce 16-21 ab 53 e2 5b 22 3b 41   ....t...!.S.[";A
        0040 - 82 dc 11 d3 a5 1c 72 d9-17 11 f8 cc 3b 42 a7 91   ......r.....;B..
        0050 - 6d d2 0d 11 2a 0d 8b 25-50 5c e5 65 7a e8 44 d2   m...*..%P.ez.D.
        0060 - 22 94 21 5b 8d dc b6 91-ba ee 09 95 f0 6b 75 1b   ".![.........ku.
        0070 - 90 bf 19 55 32 21 90 c4-70 c1 76 15 15 cb 9a 43   ...U2!..p.v....C
        0080 - e8 00 16 77 10 fc 7c a3-d6 8f 73 37 c9 2e b4 0e   ...w..|...s7....
        0090 - 07 d5 1d 90                                       ....

        Start Time: 1388745845
        Timeout   : 300 (sec)
        Verify return code: 0 (ok)



     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Curl和Wget访问HTTPS连接出现Unable to establish SSl connection错误

      1. wget 使用 –no-check-certificate 参数  
      2. curl 使用 -k或者--insecure 参数 

    ./curl -o aa.js https://s.ytimg.com/yts/jsbin/html5player-vf
    lG49soT.js --cacert /dvb/ca-certificates.crt

    curl: (60) SSL certificate problem, verify that the CA cert is:
    error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
    More details here: http://curl.haxx.se/docs/sslcerts.html

    curl performs SSL certificate verification by default, using a "bundle"
     of Certificate Authority (CA) public keys (CA certs). If the default
     bundle file isn't adequate, you can specify an alternate file
     using the --cacert option.
    If this HTTPS server uses a certificate signed by a CA represented in
     the bundle, the certificate verification probably failed due to a
     problem with the certificate (it might be expired, or the name might
     not match the domain name in the URL).
    If you'd like to turn off curl's verification of the certificate, use
     the -k (or --insecure) option.

    curl: curl是利用URL语法在命令行方式下工作的文件传输工具。 [百科: http://baike.baidu.com/view/1326315.htm]
    官网: http://curl.haxx.se/
    其中libcurl有C语言、Python接口(PyCurl: http://pycurl.sourceforge.net/)等等。 curl.exe也可以作为一个命令行下载工具。

    将来学习了多线程, 可以改为多线程下载大笑

    最简单的下载语法:

    curl -o [filename] <url>

    例如:

    Microsoft Windows [版本 6.0.6001]
    版权所有 (C) 2006 Microsoft Corporation。保留所有权利。
    
    C:Windowssystem32>curl -o E:MIT_BIH_Arrhythmia_Database103.dat  http://physionet.org/physiobank/database/mitdb/103.dat
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      1 1904k    1 23082    0     0   3582      0  0:09:04  0:00:06  0:08:58  3556

    这样子就从网页http://physionet.org/physiobank/database/mitdb/103.dat把文件103.dat下载到本地E盘E:MIT_BIH_Arrhythmia_Database103.dat

    curl --head <url>

    获取下载文件的大小。例如:

    C:Windowssystem32>curl --head http://physionet.org/physiobank/database/mitdb/100.atr
    HTTP/1.1 200 OK
    Date: Mon, 28 Nov 2011 05:35:46 GMT
    Server: Apache/2.2.17 (Fedora)
    Last-Modified: Thu, 30 Jul 1992 01:21:18 GMT
    ETag: "82c1c18-11ce-287fa5a2e9f80"
    Accept-Ranges: bytes
    Content-Length: 4558
    Connection: close
    Content-Type: application/octet-stream

    curl --connect-timeout <seconds> <url>

    (参考: http://blog.csdn.net/learnhard/article/details/5683703)

    连接超时时间设置。

    curl -m <seconds> <url>

    传输数据超时时间设置。 例如:

    C:Windowssystem32>curl -o E:MIT_BIH_Arrhythmia_Database104.dat  -m 20 "http://physionet.org/physiobank/database/mitdb/104.dat"
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      1 1904k    1 20162    0     0    953      0  0:34:06  0:00:21  0:33:45   377
    curl: (28) Operation timed out after 20000 milliseconds with 20162 out of 195000
    0 bytes received

    更多命令请参考:

    http://blog.csdn.net/lizhitao/article/details/6039473

    # !/usr/bin/env python
    # Filename: down.py
    # download files from http://physionet.org/physiobank/database/mitdb/
    
    import os
    
    home = r"E:MIT_BIH_Arrhythmia_Database"
    fext = [".atr", ".dat", ".hea"]
    hurl = r"http://physionet.org/physiobank/database/mitdb/"
    
    for ext in fext:
        for index in range(100, 234):
            fname  = str(index) + ext
            fsave  = home + os.path.sep + fname
            fget   = hurl + fname
            if False == os.path.isfile(fsave):
                command = "curl -o " + fsave + " " + fget
                os.system(command)

    http://blog.csdn.net/sjin_1314/article/details/17392675

  • 相关阅读:
    使用Vue初始化项目的时候,一直download template的解决方案
    移动端复选框和单选框选中样式不能正常显示
    PC端360浏览器如何打开手机模式
    我在项目中是这样配置Vue的
    怎么取消微信pc端“保持微信窗口在最前面”设置?
    5个 Vuex 插件,给你的下个VueJS项目
    Vue+Element前端导入导出Excel
    前端快来!最火的 Vue.js 开源项目出炉
    1月12日学习日志
    1月9日学习日志
  • 原文地址:https://www.cnblogs.com/jingzhishen/p/3498809.html
Copyright © 2020-2023  润新知