How to create an SSL connection using the Smack XMPP library?

后端 未结 3 1784
孤城傲影
孤城傲影 2020-12-31 23:42

I\'m building a small program that acts as an XMPP client and I am using the Smack library. Now, the server I am connecting to requires SSL (in Pidgin I have to check \"Forc

3条回答
  •  遥遥无期
    2020-12-31 23:54

    Yes, it's quite easy to achieve. Take a look at the ConnectionConfiguration class, and in particular the setSecurityMode method which accepts a ConnectionConfiguration.SecurityMode enum as a parameter. Setting this to "required" forces Smack to use TLS.

    from the Javadoc:

    Securirty via TLS encryption is required in order to connect. If the server does not offer TLS or if the TLS negotiaton fails, the connection to the server will fail.

提交回复
热议问题