Bot

Authorizationに不正な値を指定すると"502 Proxy Error"が発生する

Usuba

2020.09.14既読 8235

Authorizationに不正な値を指定した以下のリクエストを送信すると、

Content-Type: application/json
consumerKey: WX8Pxxxxxxxxxxxxxxxxx
Authorization: Bearer WX8P

{
"name": "test",
"description": "test",
"managers": ["xxx@woks"],
"useDomainScope": true,
"domainIds": ["1"]
}

以下の502エラーレスポンスが返却されました。

HTTP/1.1 502 Proxy Error
Date: Mon, 14 Sep 2020 09:53:23 GMT
Server: Apache
Strict-Transport-Security: max-age=63072000; includeSubdomains; preload
Content-Length: 478
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>502 Proxy Error</title>
</head><body>
<h1>Proxy Error</h1>
<p>The proxy server received an invalid
response from an upstream server.<br />
The proxy server could not handle the request<p>Reason: <strong>DNS lookup failure for: wx8-apis.worksmobile.com</strong></p></p>
<p>Additionally, a 502 Bad Gateway
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

不正なAuthorizationの指定であるため、以下の401エラーレスポンスを期待してます。

HTTP/1.1 401 Unauthorized
Date: Mon, 14 Sep 2020 10:00:25 GMT
Server: Apache
Strict-Transport-Security: max-age=63072000; includeSubdomains; preload
Referrer-Policy: unsafe-url
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json

{
"code": "UNAUTHORIZED",
"domain": "common",
"message": "Authentication failed, no authority"
}

401エラーレスポンスでハンドリングを行いたいため、修正して頂ければ嬉しいです。

コメント10

  • 업데이트 된 답글입니다.

    LINE WORKS 公式アカウント

    不正な Token を指定した場合には以下のエラーが発生します。
    status: 401 Unauthorized
    {
      "code": "UNAUTHORIZED",
      "domain": "common",
      "message": "Authentication failed, no authority"
    }

    投稿者様のエラー内容ですが、ご利用の proxy サーバからのエラーメッセージのようです。
    ご利用の proxy サーバ担当者にご確認ください。

    2020.09.15

    0
  • 업데이트 된 답글입니다.

    Usuba 投稿者

    お忙しいところ、ご確認頂き、ありがとうございます。

    > 投稿者様のエラー内容ですが、ご利用の proxy サーバからのエラーメッセージのようです。
    > ご利用の proxy サーバ担当者にご確認ください。

    とくにproxyサーバーは利用しておりません。


    HTTPリクエストを実行した環境依存ではないかとのことなので、こちらで確認した環境を以下に記載します。

    以下のcurlコマンドで再現を確認しました。
    curl -X POST https://apis.worksmobile.com/r/xxxxxxxxxxxxx/message/v1/bot \
    -H 'Content-Type: application/json' \
    -H 'consumerKey: WX8Pxxxxxxxxxxxxxxxx' \
    -H 'Authorization: Bearer WX8P' \
    -d '{ \
     "name": "test", \
     "photoUrl": "https://developers.worksmobile.com/favicon.png";, \
     "description": "test", \
     "managers": ["xxx@woks"], \
     "useDomainScope": true, \
     "domainIds": ["1"] \
    }'

    以下のネットワークで再現することを確認しました。
    J:COM
    UQ WiMax
    Softbank

    セキュリティソフトが問題かもしれないと思いましたので、
    以下のセキュリティソフトがインストールされている端末で再現を確認しました。
    CrowdStrike
    ウイルスバスター

    端末が原因かもしれないと思いましたので、
    以下の端末で再現してます。
    macbook
    AWS EC2インスタンス (Amazon Linux)

    全ての環境で共通して利用しているProxyサーバはありません。

    大変恐縮ですが、引き続きご確認の程よろしくお願い申し上げます。

    2020.09.15

    0
  • 업데이트 된 답글입니다.

    Usuba 投稿者

    curlコマンドの実行結果です。

    % curl -v -X POST https://apis.worksmobile.com/r/xxxxxxxxxxxxx/message/v1/bot \
    -H 'Content-Type: application/json' \
    -H 'consumerKey: WX8Pxxxxxxxxxxxxxxxx' \
    -H 'Authorization: Bearer WX8P' \
    -d '{ \
    "name": "test", \
    "photoUrl": "https://developers.worksmobile.com/favicon.png";;, \
    "description": "test", \
    "managers": ["xxx@woks"], \
    "useDomainScope": true, \
    "domainIds": ["1"] \
    }'
    Note: Unnecessary use of -X or --request, POST is already inferred.
    *   Trying 203.104.170.18...
    * TCP_NODELAY set
    * Connected to apis.worksmobile.com (203.104.170.18) port 443 (#0)
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * successfully set certificate verify locations:
    *   CAfile: /etc/ssl/cert.pem
     CApath: none
    * TLSv1.2 (OUT), TLS handshake, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Server hello (2):
    * TLSv1.2 (IN), TLS handshake, Certificate (11):
    * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
    * TLSv1.2 (IN), TLS handshake, Server finished (14):
    * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
    * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
    * TLSv1.2 (OUT), TLS handshake, Finished (20):
    * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
    * TLSv1.2 (IN), TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
    * ALPN, server did not agree to a protocol
    * Server certificate:
    *  subject: C=KR; ST=Gyeonggi-do; L=Seongnam-si; O=Works mobile Corp.; CN=worksmobile.com
    *  start date: Apr  8 00:00:00 2019 GMT
    *  expire date: Jun  1 12:00:00 2021 GMT
    *  subjectAltName: host "apis.worksmobile.com" matched cert's "*.worksmobile.com"
    *  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018
    *  SSL certificate verify ok.
    > POST /r/xxxxxxxxxxxxx/message/v1/bot HTTP/1.1
    > Host: apis.worksmobile.com
    > User-Agent: curl/7.64.1
    > Accept: */*
    > Content-Type: application/json
    > consumerKey: WX8Pxxxxxxxxxxxxxxxx
    > Authorization: Bearer WX8P
    > Content-Length: 194
    >
    * upload completely sent off: 194 out of 194 bytes
    < HTTP/1.1 502 Proxy Error
    < Date: Tue, 15 Sep 2020 08:58:38 GMT
    < Server: Apache
    < Strict-Transport-Security: max-age=63072000; includeSubdomains; preload
    < Content-Length: 478
    < Connection: close
    < Content-Type: text/html; charset=iso-8859-1
    <
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>502 Proxy Error</title>
    </head><body>
    <h1>Proxy Error</h1>
    <p>The proxy server received an invalid
    response from an upstream server.<br />
    The proxy server could not handle the request<p>Reason: <strong>DNS lookup failure for: wx8-apis.worksmobile.com</strong></p></p>
    <p>Additionally, a 502 Bad Gateway
    error was encountered while trying to use an ErrorDocument to handle the request.</p>
    </body></html>
    * Closing connection 0
    * TLSv1.2 (OUT), TLS alert, close notify (256):

    2020.09.15

    0
  • 업데이트 된 답글입니다.

    LINE WORKS 公式アカウント

    記載していただいたコードを拝見させていただきました。
    photoUrl のパラメータの最後にセミコロンがございます。
    こちらを削除したうえで実行してみてください。

    2020.09.15

    0
  • 업데이트 된 답글입니다.

    Usuba 投稿者

    お忙しいところ、ご確認いただきありがとうございます。

    curlコマンドに書き換える際に誤りがございました。
    失礼いたしました。

    セミコロンをのぞき、再実行して確認いたしました。
    レスポンスは変わらず502エラーでございました。

    以下、実行結果です。

    % curl -v -X POST https://apis.worksmobile.com/r/xxxxxxxxxxxxx/message/v1/bot \
    -H 'Content-Type: application/json' \
    -H 'consumerKey: WX8Pxxxxxxxxxxxxxxxx' \
    -H 'Authorization: Bearer WX8P' \
    -d '{ \
    "name": "test", \
    "photoUrl": "https://developers.worksmobile.com/favicon.png";, \
    "description": "test", \
    "managers": ["xxx@woks"], \
    "useDomainScope": true, \
    "domainIds": ["1"] \
    }'
    Note: Unnecessary use of -X or --request, POST is already inferred.
    *   Trying 203.104.170.18...
    * TCP_NODELAY set
    * Connected to apis.worksmobile.com (203.104.170.18) port 443 (#0)
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * successfully set certificate verify locations:
    *   CAfile: /etc/ssl/cert.pem
     CApath: none
    * TLSv1.2 (OUT), TLS handshake, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Server hello (2):
    * TLSv1.2 (IN), TLS handshake, Certificate (11):
    * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
    * TLSv1.2 (IN), TLS handshake, Server finished (14):
    * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
    * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
    * TLSv1.2 (OUT), TLS handshake, Finished (20):
    * TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
    * TLSv1.2 (IN), TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
    * ALPN, server did not agree to a protocol
    * Server certificate:
    *  subject: C=KR; ST=Gyeonggi-do; L=Seongnam-si; O=Works mobile Corp.; CN=worksmobile.com
    *  start date: Apr  8 00:00:00 2019 GMT
    *  expire date: Jun  1 12:00:00 2021 GMT
    *  subjectAltName: host "apis.worksmobile.com" matched cert's "*.worksmobile.com"
    *  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018
    *  SSL certificate verify ok.
    > POST /r/xxxxxxxxxxxxx/message/v1/bot HTTP/1.1
    > Host: apis.worksmobile.com
    > User-Agent: curl/7.64.1
    > Accept: */*
    > Content-Type: application/json
    > consumerKey: WX8Pxxxxxxxxxxxxxxxx
    > Authorization: Bearer WX8P
    > Content-Length: 193
    >
    * upload completely sent off: 193 out of 193 bytes
    < HTTP/1.1 502 Proxy Error
    < Date: Tue, 15 Sep 2020 09:37:14 GMT
    < Server: Apache
    < Strict-Transport-Security: max-age=63072000; includeSubdomains; preload
    < Content-Length: 478
    < Connection: close
    < Content-Type: text/html; charset=iso-8859-1
    <
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>502 Proxy Error</title>
    </head><body>
    <h1>Proxy Error</h1>
    <p>The proxy server received an invalid
    response from an upstream server.<br />
    The proxy server could not handle the request<p>Reason: <strong>DNS lookup failure for: wx8-apis.worksmobile.com</strong></p></p>
    <p>Additionally, a 502 Bad Gateway
    error was encountered while trying to use an ErrorDocument to handle the request.</p>
    </body></html>
    * Closing connection 0
    * TLSv1.2 (OUT), TLS alert, close notify (256):

    大変恐縮ですが、引き続きご確認の程よろしくお願い申し上げます。

    2020.09.15

    0
  • 업데이트 된 답글입니다.

    Usuba 投稿者

    コメントでcurlコマンドを書き込むと正常に表示されないため、画像で投稿させて頂きます。

    2020.09.15

    0
  • 업데이트 된 답글입니다.

    LINE WORKS 公式アカウント

    エラー内容を確認したところ、SSL 通信時のエラーのようです。
    * ALPN, server did not agree to a protocol
    *  SSL certificate verify ok.


    インストールされているルート証明書を最新に更新の上、お試しください。

    2020.09.17

    0
  • 업데이트 된 답글입니다.

    Usuba 投稿者

    ご返信頂きありがとうございます。
    クライアントのルート証明書が問題ではないかということですが、
    私はクライアントのルート証明書が原因ではないと考えております。

    その根拠を説明させて頂きます。

    ```
    1. 複数のクライアント/ネットワークの環境で発生する
    以下のクライアント9台で本現象が発生することを確認しております。
    A社の業務PC 3台
    B社の業務PC 3台
    C社の業務PC 1台
    私物のPC 1台
    AWSのEC2インスタンス 1台

    テレワークで作業しているため、各々のクライアントは別々のネットワークに接続されています。
    Proxyサーバのようなネットワークを仲介するサーバーもありません。

    複数のクライアント環境とネットワーク環境で必ず発生しているため、
    クライアント側の環境に依存して発生している現象である可能性は低いと考えております。

    2. Authorizationに正常なTokenを指定するとリクエストが成功する
    Authorizationに正常なTokenを指定するとリクエストが成功することを確認できております。
    ルート証明書に問題がありSSL通信エラーが発生するとしたら、リクエストが成功することはないはずです。
    そのため、ルート証明書が原因で発生している可能性は低いと考えております。

    3. Authorizationに特定の文字列を指定した時に発生する
    Authorizationに英字2文字と数字1文字と英字1文字で始まる文字列を指定すると、本現象が発生することを確認しております。

    こちらで現象を確認できた文字列は以下です。
    Authorization: Bearer WX8P
    Authorization: Bearer WX8PP
    Authorization: Bearer aa1a
    Authorization: Bearer ui7x

    "Authorization: Bearer aaaa"のような文字列を指定すると、本現象は発生しないことを確認してます。
    Authorizationに指定する値によって動作が変わるということが、ルート証明書が原因ではない可能性を示していると考えております。
    ```

    クライアント側の環境に依存しているかどうかを確認する方法があります。
    その方法をご提案させてください。
    LINE WORKS様でも以下のcurlコマンドを実行して頂き、502エラーが発生するかをご確認頂きたいです。

    ```
    curl -X POST https://apis.worksmobile.com/r/xxxxxxxxxxxxx/message/v1/bot \
    -H 'Content-Type: application/json' \
    -H 'consumerKey: WX8Pxxxxxxxxxxxxxxxx' \
    -H 'Authorization: Bearer WX8P' \
    -d '{
    "name": "test",
    "photoUrl": "https://developers.worksmobile.com/favicon.png";,
    "description": "test",
    "managers": ["xxx@woks"],
    "useDomainScope": true,
    "domainIds": ["1"]
    }'
    ```

    コメントを投稿するとphotoUrlパラメータに何故かセミコロンが表示されるため、
    photoUrlパラメータに表示されているセミコロンは削除して実行して頂ければと思います。

    大変恐縮ですが、ご検討の程よろしくお願い申し上げます。

    2020.09.17

    0
  • 업데이트 된 답글입니다.

    LINE WORKS 公式アカウント

    詳細な情報提供、ありがとうございました。
    いただいた情報で確認を取りましたところ、特定の文字列を指定した時に発生することを確認いたしました。

    開発に要請し、401 UNAUTHORIZED ERROR が Response されるように修正を行いました。
    ご迷惑をおかけしてしまい、大変申し訳ございませんでした。
    お手数をおかけいたしますが動作をお確かめください。

    2020.09.25

    1
  • 업데이트 된 답글입니다.

    Usuba 投稿者

    ご修正いただきありがとうございます。
    修正されたことを確認できました。
    ご対応の程ありがとうございました

    2020.09.30

    0
前の投稿 Api not exists のエラーが急に出るようになりました
次の投稿メッセージ送信時に"Malformed authentication header"が発生
リスト

まだ、解決できませんか?
今すぐ実際に使用しているLINE WORKSユーザーに質問してみましょう。