标签:CertPathValidatorException 235.122 登录 certification smack Smack 169.254 使用 org
①android studio添加smack库依赖
repositories { maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } mavenCentral() } dependencies { compile "org.igniterealtime.smack:smack-android:4.3.0" compile "org.igniterealtime.smack:smack-tcp:4.3.0" } configurations { all*.exclude group: 'xpp3', module: 'xpp3' }
(
我试过下载smack的完整jar包,再手动添加,出现很多缺少第三方依赖库的情况;
再有试过添加smack4.2版本的依赖,报空指针异常
)
②登录
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) login("admin","yourpassword") } fun login(username:String,password:String){ var addr:InetAddress = InetAddress.getByName("169.254.235.122") val config: XMPPTCPConnectionConfiguration = XMPPTCPConnectionConfiguration.builder() .setUsernameAndPassword(username,password) .setXmppDomain("169.254.235.122") .setHost("169.254.235.122") .setHostAddress(addr) .setPort(5222) .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled) // .setSendPresence(true) // .setDebuggerEnabled(true) .build() Thread{ kotlin.run { val conn:XMPPTCPConnection = XMPPTCPConnection(config) try{ conn.connect().login() println("登录成功...") }catch (e:Exception){ println("登录错误...") e.printStackTrace() } } }.start() } }
说明:
openfire相关配置
参考
Android Studio 使用 smack4.3 搭建 Openfire+smack 开源IM开发环境
错误提示:
org.jivesoftware.smack.SmackException$ConnectionException: The following addresses failed: '169.254.235.122:5222' failed because: org.minidns.hla.ResolutionUnsuccessfulException: Asking for 169.254.235.122. IN A yielded an error response NX_DOMAIN,
解决方案:
error-on-smack-4-2-0-in-aaaa-yielded-an-error-response-nx-domain
错误提示:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
...
解决方案:
设置安全模式:
setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
错误提示:
org.jivesoftware.smack.sasl.SASLErrorException: SASLError using SCRAM-SHA-1: not-authorized
原因:
大概就是密码错误
标签:CertPathValidatorException,235.122,登录,certification,smack,Smack,169.254,使用,org 来源: https://www.cnblogs.com/vocus/p/14208772.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。