dongxian6715 2014-05-06 11:50
浏览 16
已采纳

我可以互换地在URL中使用ssl://和https://吗?

I have to write some PHP code to make a post request to an external server and got two different examples from the server owners, one using "ssl://" and the other "https://" in the URL.

Can they be used interchangeably? Where would this be documented? Thank you!

EDIT to include PHP code (not sure why I can't format the code properly, if someone can help with explaining how to incorporate the initial comment in the code block):

// make a http post request to an external server
function httpPost($host, $usepath, $postdata = "") {

    $fp = fsockopen($host, 443, $errno, $errstr, 60);
    if( !$fp ) {
        print "$errstr ($errno)<br>
";
    }
    else {
        fwrite( $fp, "POST $usepath HTTP/1.0
");
        $strlength = strlen( $postdata );
        fwrite( $fp, "Content-type: application/x-www-form-urlencoded
" );
        fwrite( $fp, "Content-length: ".$strlength."

" );
        fwrite( $fp, $postdata."

" );

        $output = "";

        while( !feof( $fp ) ) {
            $output .= fgets( $fp, 1024);
        }

        fclose( $fp);
    }

    return $output;
}
  • 写回答

2条回答 默认 最新

  • dtol41388 2014-05-06 14:16
    关注

    ssl:// URLs are quite specific to PHP. It's the way PHP provides a way to use a direct SSL/TLS connection when using its fsocketopen function. See List of Supported Socket Transports in the manual.

    ssl:// will give you an SSL/TLS connection without any application protocol on top of it: it will be up to your application to implement whichever protocol you require for the communication.

    In contrast, https:// will implement the HTTP protocol over this SSL/TLS connection.

    Note that the default settings for ssl:// and tls:// are rather poor in terms of security. In particular, the default value for verify_peer is false, which would make the connection vulnerable to MITM attacks.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏