dops57958 2016-08-24 02:19 采纳率: 0%
浏览 28

PHP检查是否有可能获得SSL

Well I do not own a wildcard SSL for my homepage, but I have a quite few subdomains that is included in my SSL Certificate, but I wanna see if there would be plausible to check if the subdomain has a valid ceritificate before redirecting to the subdomain in HTTPS.

Why do i want to know this? because I'm running all my domains through one php file, thats meant for DomainControll, that's including a database for what pages exists and such, but instead of having an extra row in the mysql weather not its awailable in HTTPS is kind-off waste, but if there isn't this would be the answer for my question. Hopefully there exists a way to do what i wish.

Thanks ~Martin

  • 写回答

1条回答 默认 最新

  • douqian1835 2016-08-24 02:31
    关注

    You can use curl to test. If CURLOPT_SSL_VERIFYPEER is set to true (the default), the result will be false.

    <?php 
    $ch = curl_init('https://www.example.org');
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
    $result = curl_exec($ch);
    echo curl_error($ch);
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
    $result = curl_exec($ch);
    echo curl_error($ch);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)