Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https check issue #486

Closed
nosun opened this issue Aug 10, 2016 · 4 comments
Closed

https check issue #486

nosun opened this issue Aug 10, 2016 · 4 comments

Comments

@nosun
Copy link

nosun commented Aug 10, 2016

我用的环境

PHP 版本: 无关
overtrue/wechat 版本: 2.1.*

问题及现象 Https 判断 不准确导致 签名验证失败

文件位置: overtrue/wechat/src/Wechat/Url.php

function :

    /**
     * 获取当前URL.
     *
     * @return string
     */
    public static function current()
    {
        $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
                        || $_SERVER['SERVER_PORT'] === 443) ? 'https://' : 'http://';

        if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
            $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
        } else {
            $host = $_SERVER['HTTP_HOST'];
        }

        return $protocol.$host.$_SERVER['REQUEST_URI'];
    }

我使用的是 https 但端口不是 443, 第一个判断 貌似也没得到是 https,结果认为是 http, 导致签名错误,需要我手动修复包.

@overtrue
Copy link
Collaborator

为啥要弄非 443?

@ac1982
Copy link
Contributor

ac1982 commented Aug 10, 2016

愿意告诉我,你不使用默认端口443的原因吗?主流的Web Server都支持SNI,因为我用的是Nginx,这里是参考地址https://nginx.org/en/docs/http/configuring_https_servers.html

@nosun
Copy link
Author

nosun commented Aug 11, 2016

当时上线的时候使用的是 http的, 使用的是阿里云的服务器, 后来改成 https, 但是https 的配置是在阿里云 的 代理层做的, 估计是这个原因,进到内部服务器的时候转发的实际是 http 的请求, 内部端口一直都使用的是80.

这样说来, 可能 https 的 check 可能也无问题, 我和运维说下把内部映射的端口改一下吧.

@nosun
Copy link
Author

nosun commented Aug 11, 2016

也可以考虑增加说明, 或者配置项, 虽然像我这样的情况不多,但是不小心也会遇到

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants