【问题标题】:Disable SSL in PHP imagepng在 PHP imagepng 中禁用 SSL
【发布时间】:2016-09-12 11:06:02
【问题描述】:

当我尝试在 PHP 中调用 imagepng 时遇到 SSL 错误。

Message: imagecreatefrompng(): SSL operation failed with code 1

我知道在使用 get_put_contents() 时可以禁用 SSL 验证,但您可以使用 imagepng 来执行此操作吗?谢谢。

【问题讨论】:

    标签: php image ssl image-processing


    【解决方案1】:

    不是直接的,但您应该可以将file_get_contents 与imagecreatefromstring 结合起来,例如

    $context = [
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
        ],
    ];
    
    $url = 'https://www.google.co.uk/images/nav_logo242.png';
    $response = file_get_contents($url, false, stream_context_create($context));
    
    $img = imagecreatefromstring($response);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-08-05
      • 1970-01-01
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多