首页 > 解决方案 > WSO2 iOT iOS Agent 无法登录

问题描述

我们面临 IOS 设备注册到 wso2 IoT 服务器 3.3.0 的问题。我们按照此文档https://docs.wso2.com/display/IOTS330/iOS+Configurations安装了 IOS 特色证书和 MDM 证书。但是当从 IOS 注册而不使用 safari 的代理时,它会抛出 500 错误

HTTP Status 500 - org.mozilla.javascript.JavaScriptException: Error: {/app/modules/oauth/token-handlers.js} Could not set up access token pair by password grant type. Encoded client credentials are missing - setupTokenPairByPasswordGrantType(x, y) (/ios-web-agent/app/modules/oauth/token-handlers.js#44)
Status report
org.mozilla.javascript.JavaScriptException: Error: {/app/modules/oauth/token-handlers.js} Could not set up access token pair by password grant type. Encoded client credentials are missing - setupTokenPairByPasswordGrantType(x, y) (/ios-web-agent/app/modules/oauth/token-handlers.js#44)
description
The server encountered an internal error that prevented it from fulfilling this request.
Apache Tomcat/7.0.85

我们尝试创建新的租户和用户,但没有运气。请参阅下面的 wso2carbon.log。似乎 API 调用https://IOT-SERVER:9443/api-application-registration/register/tenants?tenantDomain=carbon.super&applicationName=ios-webapp-carbon.super以 401 失败。请您帮助我们解决这个?

0 bytes written {org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,784] DEBUG -  http-outgoing-397: Produce output {org.apache.synapse.transport.http.conn.LoggingNHttpClientConnection}

[2018-08-28 00:34:45,784] DEBUG -  I/O session http-outgoing-397-250 192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][1189][0]: 1105 bytes written {org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "POST /api-application-registration/register/tenants?tenantDomain=carbon.super&applicationName=ios-webapp-carbon.super HTTP/1.1[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "X-JWT-Assertion: eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOi************************************kbWluQGNhcmJvbi5zdXBlciIsImV4cCI6MTUzNTUwMTY4NSwiaWF0IjoxNTM1NDQxNjg1LCJqdGkiOiIxNTM1NDQxNjg1NjkwMTQ5NTMwODMxNyJ9.jvxyzu4CwQKKJy2HL-H48PxP-9jOR1qC_ca_I3WbU3EuBe4yYw6RxYuWZOsNLJWsy77S_KPl3WlV4gUGnd4IsQHEnMARv_dYCtsEqpxAcT6Ga2ysfwCCtsuitgb_va65QmbYsBiMz2TOS-dVzzrdcbmljnTwUybvkAvCRY-R-ym16WgY7LY-mV2P5q-2q-DTeor6uGHFYrbuWaYIP3WlcoWByzIlsKbKnMGRTfal5bEIMmDg77Ah73CKj1V2NX0PugywEUmplEXAICBzvGlw4Ee5NuvllqDiNtER1fKkWnGgrZt561bi2D1436MQi4Tpy1dm_Qh2P0wMKQD6-FmNtw[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "Content-Type: application/json; charset=UTF-8[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "Transfer-Encoding: chunked[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "Host: IOT server:9443[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "Connection: Keep-Alive[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "0[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,786] DEBUG -  I/O session http-outgoing-397-250 192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][1189][0]: Clear event [w] {org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,786] DEBUG -  Adding tenant: -1234, isTenantLoaded: false {org.wso2.carbon.registry.indexing.internal.IndexingServiceComponent}

[2018-08-28 00:34:45,786] DEBUG -  Size of initializedTenants after adding tenant -1234: 1 {org.wso2.carbon.registry.indexing.internal.IndexingServiceComponent}

[2018-08-28 00:34:45,788] DEBUG -  Failed to authorize incoming request , API : %2Fapi-application-registration%2Fregister%2Ftenants {org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticationValve}

[2018-08-28 00:34:45,788] DEBUG -  http-outgoing-397: Consume input {org.apache.synapse.transport.http.conn.LoggingNHttpClientConnection}

[2018-08-28 00:34:45,788] DEBUG -  I/O session http-outgoing-397-250 192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0][0]: 195 bytes read {org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "HTTP/1.1 401 Unauthorized[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Content-Type: application/xml;charset=UTF-8[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Content-Length: 36[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Date: Tue, 28 Aug 2018 07:34:45 GMT[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Server: WSO2 Carbon Server[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Failed to authorize incoming request" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  http-outgoing-397 << HTTP/1.1 401 Unauthorized {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,789] DEBUG -  http-outgoing-397 << Content-Type: application/xml;charset=UTF-8 {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,789] DEBUG -  http-outgoing-397 << Content-Length: 36 {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,790] DEBUG -  http-outgoing-397 << Date: Tue, 28 Aug 2018 07:34:45 GMT {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,790] DEBUG -  http-outgoing-397 << Server: WSO2 Carbon Server {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,790] DEBUG -  I/O session http-outgoing-397-250 192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0][0]: Set attribute RES_HEADER_ARRIVAL_TIME {org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,790] DEBUG -  I/O session http-outgoing-397-250 192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][0][0][0][0]: Set attribute RES_FROM_BACKEND_READ_START_TIME {org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,790] DEBUG -  I/O session http-incoming-860-249 192.168.3.216:8243<->192.168.3.216:41245[ACTIVE][:r][ACTIVE][][NOT_HANDSHAKING][0][0][0][0]: Set attribute CLIENT_WORKER_INIT_TIME {org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,790] DEBUG -  getAction (null) from org.apache.axis2.client.Options@5314693d {org.apache.axis2.client.Options}

[2018-08-28 00:34:45,790] DEBUG -  Old SoapAction is (null) {org.apache.axis2.context.MessageContext}

标签: javaioswso2wso2carbon

解决方案


抛出的错误是:移动应用程序端错误

HTTP 状态 500 - org.mozilla.javascript.JavaScriptException:错误:{/app/modules/oauth/token-handlers.js} 无法按密码授予类型设置访问令牌对。缺少编码的客户端凭据 - setupTokenPairByPasswordGrantType(x, y) (/ios-web-agent/app/modules/oauth/token-handlers.js#44) 状态报告 org.mozilla.javascript.JavaScriptException: Error: {/app/ modules/oauth/token-handlers.js} 无法通过密码授予类型设置访问令牌对。缺少编码的客户端凭据 - setupTokenPairByPasswordGrantType(x, y) (/ios-web-agent/app/modules/oauth/token-handlers.js#44) 描述 服务器遇到内部错误,阻止它完成此请求。Apache Tomcat/7.0.85

服务器 wso2carbon.log :

0 bytes written {org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,784] DEBUG -  http-outgoing-397: Produce output 
{org.apache.synapse.transport.http.conn.LoggingNHttpClientConnection}

[2018-08-28 00:34:45,784] DEBUG -  I/O session http-outgoing-397-250
192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][rw:w][ACTIVE][rw] . 
[NOT_HANDSHAKING][0][0][1189][0]: 1105 bytes written 
{org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "POST 
/api-application-registration/register/tenants?            
tenantDomain=carbon.super&applicationName=ios-webapp-carbon.super 
HTTP/1.1[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "X-JWT- 
Assertion: eyJhbGciOiJSUzI1NiJ9.eyJzdWI7LY-mV2P5q-2q-  
{org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "Content- 
Type: application/json; charset=UTF-8[\r][\n]" 
{org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << 
"Transfer-Encoding: chunked[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "Host: 
IOT server:9443[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << 
"Connection: Keep-Alive[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "User- 
Agent: Synapse-PT-HttpComponents-NIO[\r][\n]" 
{org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "[\r] . 
[\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "0[\r] . 
[\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,785] DEBUG -  HTTPS-Sender I/O dispatcher-4 << "[\r] . 
[\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,786] DEBUG -  I/O session http-outgoing-397-250
192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][rw:w][ACTIVE][rw] . 
[NOT_HANDSHAKING][0][0][1189][0]: Clear event [w] 
{org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,786] DEBUG -  Adding tenant: -1234, isTenantLoaded: 
false {org.wso2.carbon.registry.indexing.internal.IndexingServiceComponent}

[2018-08-28 00:34:45,786] DEBUG -  Size of initializedTenants after adding 
tenant -1234: 1 
{org.wso2.carbon.registry.indexing.internal.IndexingServiceComponent}

[2018-08-28 00:34:45,788] DEBUG -  Failed to authorize incoming request , API 
: %2Fapi-application-registration%2Fregister%2Ftenants 
{org.wso2.carbon.webapp.authenticator.framework.WebappAuthenticationValve}

[2018-08-28 00:34:45,788] DEBUG -  http-outgoing-397: Consume input 
{org.apache.synapse.transport.http.conn.LoggingNHttpClientConnection}

[2018-08-28 00:34:45,788] DEBUG -  I/O session http-outgoing-397-250
192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][r:r][ACTIVE][r] . 
[NOT_HANDSHAKING][0][0][0][0]: 195 bytes read 
{org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "HTTP/1.1 
401 Unauthorized[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Content- 
Type: application/xml;charset=UTF-8[\r][\n]" 
{org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Content- 
Length: 36[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Date: 
Tue, 28 Aug 2018 07:34:45 GMT[\r][\n]" 
{org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Server: 
WSO2 Carbon Server[\r][\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "[\r] . 
[\n]" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  HTTPS-Sender I/O dispatcher-4 >> "Failed 
to authorize incoming request" {org.apache.synapse.transport.http.wire}

[2018-08-28 00:34:45,789] DEBUG -  http-outgoing-397 << HTTP/1.1 401 
Unauthorized {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,789] DEBUG -  http-outgoing-397 << Content-Type: 
application/xml;charset=UTF-8 {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,789] DEBUG -  http-outgoing-397 << Content-Length: 36 
{org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,790] DEBUG -  http-outgoing-397 << Date: Tue, 28 Aug 
2018 07:34:45 GMT {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,790] DEBUG -  http-outgoing-397 << Server: WSO2 Carbon 
Server {org.apache.synapse.transport.http.headers}

[2018-08-28 00:34:45,790] DEBUG -  I/O session http-outgoing-397-250
192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][r:r][ACTIVE][r] . 
[NOT_HANDSHAKING][0][0][0][0]: Set attribute RES_HEADER_ARRIVAL_TIME 
{org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,790] DEBUG -  I/O session http-outgoing-397-250
192.168.3.216:54504<->192.168.3.216:9443[ACTIVE][r:r][ACTIVE][r] . 
[NOT_HANDSHAKING]    [0][0][0][0]: Set attribute 
RES_FROM_BACKEND_READ_START_TIME 
{org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,790] DEBUG -  I/O session http-incoming-860-249
192.168.3.216:8243<->192.168.3.216:41245[ACTIVE][:r][ACTIVE][] . 
[NOT_HANDSHAKING] . 
[0][0][0][0]: Set attribute CLIENT_WORKER_INIT_TIME 
{org.apache.http.nio.reactor.ssl.SSLIOSession}

[2018-08-28 00:34:45,790] DEBUG -  getAction (null) from 
org.apache.axis2.client.Options@5314693d {org.apache.axis2.client.Options}

[2018-08-28 00:34:45,790] DEBUG -  Old SoapAction is (null) 
{org.apache.axis2.context.MessageContext}

使固定:

编辑 IOT_HOME/repository/deployment/server/jaggeryapps/ios-web-agent/app/conf/config.json 并将 owner 和 adminUser 更改为 'g****@carbon.super' ,没有任何文件提到这个文件!!

  1. 修复此问题后引发另一个错误

TID: [-1234] [] [2018-08-29 04:01:18,487] ERROR {org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver} - 错误处理过程中发生错误,放弃!{org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver} org.apache.cxf.interceptor.Fault:加载程序约束违规:解析方法“org.apache.http.protocol.HttpCoreContext.(Lorg/apache/http/protocol/HttpContext; )V" 当前类的类加载器(org/wso2/carbon/webapp/mgt/loader/CarbonWebappClassLoader的实例),org/apache/http/client/protocol/HttpClientContext,和类加载器(org/eclipse的实例/osgi/internal/baseadaptor/DefaultClassLoader) 用于方法的定义类 org/apache/http/protocol/HttpCoreContext,对于 org.apache 签名中使用的类型 org/apache/http/protocol/HttpContext 具有不同的 Class 对象。

修复: https ://github.com/wso2/product-iots/issues/1818

摆脱一些 jar 文件 wso2/lib/runtime/cfx

  • httpclient-4.3.6.jar
  • httpcore-4.2.4.jar
  • commons-logging-1.1.1.jar

    1. 显示有关 Nullkey 的错误

错误 - 全局异常映射器已捕获未知异常。{org.wso2.carbon.apimgt.rest.api.util.exception.GlobalThrowableMapper} java.lang.NullPointerException at org.wso2.carbon.apimgt.rest.api.util.impl.WebAppAuthenticatorImpl.validateScopes(WebAppAuthenticatorImpl.java:152 )

java.security.InvalidKeyException:提供的密钥(空)不是实例

发生这种情况是因为我们对域 cryptocom 使用了自己的 SSL,而不是脚本生成的自签名 SSL,使用脚本生成的证书解决了这个问题。需要找到为域使用签名 SSL 的步骤。

  1. WSO2 MDM iPhone 配置文件安装问题(无效的 DER 编码,未结束)

使固定:

希望从最新的 p2 repo 重建 ios-features 扩展可以解决这个错误。


推荐阅读