Skip navigation
30069 Views 52 Replies Latest reply: May 27, 2009 9:59 AM by vargok RSS
vargok Bronze 36 posts since
Mar 10, 2009
Currently Being Moderated

Apr 7, 2009 6:36 AM

Openfire+Spark - Client X.509/PKI Certificate Support

Hi-

  How does the Spark client support Client-side X.509.  E.g., what properties do I need to set to get it to recognize a keystore and keystorePassword or prompt for keystore password?  (I'm running Spark 2.5.8 against Openfire 3.6.3.)

  Server-side SSL Certification is working fine.  I have the (self-issued) CA Certificate in both /opt/openfire/resources/security/truststore and /opt/openfire/resources/security/client.truststore; this CA issues both the server and client certificates.  I have a user-based keystore in ~/.keystore (contains mykey and the CA certificate).

 

This:  http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/ssl-guid e.html

deals with openfire (server-side) configuration and not client-side configuration, so is not of much help w/r/t Spark.

 

I have set the various system properties on the server:

xmpp.client.cert.policy
needed
xmpp.client.certificate.accept-selfsigned
false
xmpp.client.certificate.crl
/opt/openfire/resources/security/crl.pem
xmpp.client.certificate.verify
true
xmpp.client.certificate.verify.chain
true
xmpp.client.certificate.verify.root
true
xmpp.client.certificate.verify.validity
true


xmpp.client.tls.policy
required
xmpp.socket.ssl.client.truststore
/opt/openfire/resources/security/client.truststore

 

Other posts have posed the question, but there's no complete guide on HOW TO do this.

E.g.,

- http://www.igniterealtime.org/community/message/137320#137320

- http://www.igniterealtime.org/community/message/176779#176779

- http://www.igniterealtime.org/community/message/113186#113186

- http://www.igniterealtime.org/community/message/168691#168691

- http://www.igniterealtime.org/community/message/186321#186321

- http://www.igniterealtime.org/community/message/157890#157890

- http://www.igniterealtime.org/community/message/158460#158460

 

Would it be possible to put together an end-to-end HOW TO on this?  For both Server-side and Client-side configuration?

 

Thanks,

Kevin

 

Forgot to note that 'xmpp.socket.ssl.client.truststore' was set. - vargok

  • slushpupie KeyContributor 776 posts since
    Jan 27, 2006

    First off, The 2.5.8 release dosnt have PKI support, I added that support after the release, so its in SVN.  When Jive does the next release the code will be there. I think the 2.6.0 beta has everything needed in there.  There is a tab in preferences for setting up PKI stuff.  Not many people (read: close to 0) are using it, so there might be some bugs lurking in there.  I never did much with the keystore format, but there is some basic support for it (I use the PKCS#11 modules)

    • slushpupie KeyContributor 776 posts since
      Jan 27, 2006
      Currently Being Moderated
      Apr 13, 2009 10:28 AM (in response to vargok)
      Re: Openfire+Spark - Client X.509/PKI Certificate Support

      Debugging SSL is hard to do, since you cant easily snoop the traffic.  A very helpful tool Ive used for this is ssldump (a friend of the tcpdump utility).  It will give you details of the SSL handshake (as much as it can).  If you have the private keys invovled it can even do decryption for certain types of connections.

       

      Also, this page is very helpful:  http://java.sun.com/j2se/1.5.0/docs/guide/security/jsse/ReadDebug.html  In essence, set the java commandline option -Djavax.net.debug=all and you will see LOTS of output.  But it shows the certificate selection process, etc.  Try that with Spark, and see if there is anything useful there.  Its possible the server certificate issuer (itself, if self-signed) is not trusted by the client. If the client does not trust the server cert, it will not attempt to continue the SSL handshake.  Sadly the error handling/reporting in spark isnt great- I never really perfected it since no one ended up using my changes.

          • slushpupie KeyContributor 776 posts since
            Jan 27, 2006
            Currently Being Moderated
            Apr 14, 2009 9:08 AM (in response to vargok)
            Re: Openfire+Spark - Client X.509/PKI Certificate Support

            Access to the keystore is handled via callback handler, so it would prompt the user when logging in (it was designed for smartcards, so it would say "Enter pin for your smartcard" or something like it). 

             

            Then java decides which client cert to use based on the list of CA's presented from the server.  So if the server provides no acceptable CA's, the client wont know which cert to use.  

              • slushpupie KeyContributor 776 posts since
                Jan 27, 2006
                Currently Being Moderated
                Apr 17, 2009 7:20 AM (in response to vargok)
                Re: Openfire+Spark - Client X.509/PKI Certificate Support

                I dont think so, but lets try something.

                 

                Please run this command:

                 

                openssl s_client -prexit -connect  yourjabberserverhostname:5223

                 

                When this connects, it should do several things:

                 

                Display the certificate subject name the server is using

                Show the certificate chain the server is using

                Show the server certificate

                Show the list of acceptable client certificate CAs

                Show some info about the specific connection

                 

                See if the server is actually sending a list of client CA's.

                  • slushpupie KeyContributor 776 posts since
                    Jan 27, 2006
                    Currently Being Moderated
                    Apr 20, 2009 7:46 AM (in response to vargok)
                    Re: Openfire+Spark - Client X.509/PKI Certificate Support

                    The openssl s_client command wont work with starttls on xmpp (it dosnt really understand the protocol) so you will want to have port 5223 (SSL) enabled to test with it.  Your output confirms my suspicion, that the server is not reading the list of CA's needed. 

                     

                    So lets make sure we have it all right:

                     

                    You have the CA you wish to authenticate clients with in the client.truststore file (imported using the keytool command)

                    The location of this file is specified in the property xmpp.socket.ssl.client.truststore

                    The password to the client.truststore file is either "changeit" or specified in xmpp.socket.ssl.client.trustpass

                    The property xmpp.client.tls.policy is set to either "wanted" or "needed" (anything else sets it to "disabled")

                    The property xmpp.client.certificate.crl is set, and points to a file with all the PEM encoded CRL's of every CA in client.truststore

                     

                    If the crl file specified, they

                      - They *must* be there

                      - They *must* be valid (not expired)

                     

                    If the file is not found (or the property is null, etc) then CRLs will not be used.  Debug output will say whats going on, just look for the lines prefixed with "ClientTrustManager: "

                     

                    OCSP is also possible if you have an OCSP responder.

                      • slushpupie KeyContributor 776 posts since
                        Jan 27, 2006
                        Currently Being Moderated
                        Apr 20, 2009 8:15 AM (in response to vargok)
                        Re: Openfire+Spark - Client X.509/PKI Certificate Support

                        have you enabled the debug log? Please look for anything from the ClientTrustManager. Often some of these messages will only happen on the first SSL/TLS session since the server started up- so perhaps shut the server down, clear the logs, start it up, and watch from the beginning.

                          • slushpupie KeyContributor 776 posts since
                            Jan 27, 2006
                            Currently Being Moderated
                            Apr 20, 2009 8:25 AM (in response to vargok)
                            Re: Openfire+Spark - Client X.509/PKI Certificate Support

                            There is a separate log file for debug messages.   Same directory, named debug.log

  • Daniel Bronze 19 posts since
    Mar 26, 2009
    Currently Being Moderated
    Apr 21, 2009 6:10 AM (in response to vargok)
    Re: Openfire+Spark - Client X.509/PKI Certificate Support

    Hi,

    I got exactly the same problem. Well I'm using Smack in Version 3.1.0 instead of Spark, but i think this is not of any relevance.

    I've debuged the TLS Handshake with -Djavax.net.debug=all.

     

    There I was able to see that the Handshake aborts at the very end of the Handshake, they even have the Mastersecret.

     

    I've appended the debug log, maybe its helpfull.

     

    Server quits with:

     

    2009.04.21 15:03:26 NIOConnection: startTLS: using c2s                 
    2009.04.21 15:03:26 ClientTrustmanager: crl file not found resources\security\crl.pem                 
    2009.04.21 15:03:26 ConnectionHandler:                  
    javax.net.ssl.SSLHandshakeException: SSL handshake failed.

    ...

    ...

    Caused by: javax.net.ssl.SSLHandshakeException: null cert chain                 
    at com.sun.net.ssl.internal.ssl.Handshaker.checkThrown(Unknown Source)                 
    at com.sun.net.ssl.internal.ssl.SSLEngineImpl.checkTaskThrown(Unknown Source)                 
    at com.sun.net.ssl.internal.ssl.SSLEngineImpl.writeAppRecord(Unknown Source)                 
    at com.sun.net.ssl.internal.ssl.SSLEngineImpl.wrap(Unknown Source)

    ...

     


    The crl File is right in place. I don't know why Openfire doesn't find it.

     

    regards Daniel

    Attachments:
      • Daniel Bronze 19 posts since
        Mar 26, 2009
        Currently Being Moderated
        Apr 23, 2009 12:30 AM (in response to vargok)
        Re: Openfire+Spark - Client X.509/PKI Certificate Support

        Hi Kevin,

        Thank you for your advice, I finally managed to implement the CRL. But the problem is still there. The same one I've metioned above. In another thread I read that the "null certificate chain error" occurs, because the client does not send his certificate. Maybe slushpupie knows how to handle that?

         

        regards

        Daniel

            • Daniel Bronze 19 posts since
              Mar 26, 2009
              Currently Being Moderated
              Apr 23, 2009 1:04 AM (in response to vargok)
              Re: Openfire+Spark - Client X.509/PKI Certificate Support

              Well I'm using Windows and a simple .exe file to install Openfire. I thing you're right, the server offers his certificate properly the only thing which is missing is the client's certificate which likely is not offered by the client. At least I think this is the problem. On client side the TLS Handshake works fine until the server closes the socket. So obviously the server doesn't get something he needs to have.

               

              I forgot, right befor the socket gets closed, on server side (Closing session due to exception: (SOCKET, R: /192.168.0.135:2395, L: /192.168.0.135:5222, S: 0.0.0.0/0.0.0.0:5222)), there is an disallowed character exception in the warnlog.

               

              Caused by: java.lang.Exception: Disallowed character                 
              at org.jivesoftware.openfire.nio.XMLLightweightParser.read(XMLLightweightParser.ja va:211)
              at org.jivesoftware.openfire.nio.XMPPDecoder.doDecode(XMPPDecoder.java:32)
              at org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(CumulativeProtoco lDecoder.java:133)                 
              at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecF ilter.java:163)                 
              ... 9 more

               

              So maybe the client trys to send something which the server doesn't understand?

               

              By the way is there a way to display the ... 9 more error lines?

              • slushpupie KeyContributor 776 posts since
                Jan 27, 2006
                Currently Being Moderated
                Apr 23, 2009 5:59 AM (in response to Daniel)
                Re: Openfire+Spark - Client X.509/PKI Certificate Support

                The server must say which CA's it will accept before the client offers any certificates. So when the server gets no certificate from the client during the handshake, it closes the connection. 

                 

                However, the errors you posted seem different.  Its like someone is trying SSL on a non-SSL port.  Is your client set to use SSL or TLS? And what port number is it connecting to?

                • Daniel Bronze 19 posts since
                  Mar 26, 2009

                  Well, on port 5223 of the Openfire Sever the OpenSSL connection test says:

                   

                  openssl s_client -prexit -connect  localhost:5223
                  CONNECTED(00000778)
                  depth=1 /C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=ca/emailAddress=none
                  verify error:num=19:self signed certificate in certificate chain
                  verify return:0
                  ---
                  Certificate chain
                  0 s:/C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=server
                     i:/C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=ca/emailAddress=none
                  1 s:/C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=ca/emailAddress=none
                     i:/C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=ca/emailAddress=none
                  ---
                  Server certificate
                  -----BEGIN CERTIFICATE-----
                  <Hash>
                  -----END CERTIFICATE-----
                  subject=/C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=server
                  issuer=/C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=ca/emailAddress=none
                  ---
                  No client certificate CA names sent
                  ---
                  SSL handshake has read 2819 bytes and written 282 bytes
                  ---
                  New, TLSv1/SSLv3, Cipher is EDH-RSA-DES-CBC3-SHA
                  Server public key is 1024 bit
                  Compression: NONE
                  Expansion: NONE
                  SSL-Session:
                      Protocol  : TLSv1
                      Cipher    : EDH-RSA-DES-CBC3-SHA
                      Session-ID: 49F5566FAD6B64E016B2577ABEA283CFB759583D564F8A1115D4476B8C92CB4
                      Session-ID-ctx:
                      Master-Key: CCB3E58B0F8A7FF98B9E7404C595BB8C2B45B8ADDBC717C93A5EECB31F4DDD73
                  3D7E89C7E480B6C75099FAC632DE06DA
                      Key-Arg   : None
                      Start Time: 1240815215
                      Timeout   : 300 (sec)
                      Verify return code: 19 (self signed certificate in certificate chain)
                  ---
                  </stream:stream>closed
                  ---
                  Certificate chain
                  0 s:/C=DE/ST=State/L=Country/O=Organisation/OU=DANE/CN=pc03
                     i:/C=DE/ST=State/L=Country/O=Organisation/OU=DANE/CN=xmpp-ca/emailAddress=none
                  1 s:/C=DE/ST=State/L=Country/O=Organisation/OU=DANE/CN=xmpp-ca/emailAddress=none
                     i:/C=DE/ST=State/L=Country/O=Organisation/OU=DANE/CN=xmpp-ca/emailAddress=none
                  ---
                  Server certificate
                  -----BEGIN CERTIFICATE-----
                  <Hash>
                  -----END CERTIFICATE-----
                  subject=/C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=server
                  issuer=/C=DE/ST=State/L=Country/O=Organisation/OU=OU/CN=ca/emailAddress=none
                  ---
                  No client certificate CA names sent
                  ---
                  SSL handshake has read 2893 bytes and written 311 bytes
                  ---
                  New, TLSv1/SSLv3, Cipher is EDH-RSA-DES-CBC3-SHA
                  Server public key is 1024 bit
                  Compression: NONE
                  Expansion: NONE
                  SSL-Session:
                      Protocol  : TLSv1
                      Cipher    : EDH-RSA-DES-CBC3-SHA
                      Session-ID: 49F5566FAD6B64E016B2577ABEA283CFB759583D564F8A1115D4476B8C92CB41
                      Session-ID-ctx:
                      Master-Key: CCB3E58B0F8A7FF98B9E7404C595BB8C2B45B8ADDBC717C93A5EECB31F4DDD73
                  3D7E89C7E480B6C75099FAC632DE06DA
                      Key-Arg   : None
                      Start Time: 1240815215
                      Timeout   : 300 (sec)
                      Verify return code: 19 (self signed certificate in certificate chain)

                  on port 5222 no certificates are offered:

                  openssl s_client -prexit -connect  localho
                  st:5222
                  Loading 'screen' into random state - done
                  CONNECTED(00000778)
                  2052:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:.\ssl\s23_lib.c:188:
                  ---
                  no peer certificate available
                  ---
                  No client certificate CA names sent
                  ---
                  SSL handshake has read 0 bytes and written 124 bytes
                  ---
                  New, (NONE), Cipher is (NONE)
                  Compression: NONE
                  Expansion: NONE
                  ---

                  Anyway on both ports I'm not able to connect to the Server. I've already postet the Errors on port 5222, here are the errors on port 5223:

                   

                  Server debug:

                   

                  2009.04.27 09:07:39 ConnectionHandler:                  
                  javax.net.ssl.SSLHandshakeException: SSL handshake failed.

                  ...

                  Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

                   

                  Client (Smack):

                  Connection failed. No response from server.

                   

                  Is there a way to tell Smack to connect via TLS or SSL? I thought the SASLMechanism handles that?

                   

                  Daniel

            • slushpupie KeyContributor 776 posts since
              Jan 27, 2006
              Currently Being Moderated
              Apr 23, 2009 5:56 AM (in response to vargok)
              Re: Openfire+Spark - Client X.509/PKI Certificate Support

              If you got it to work with Debian, then I would take a very careful look at your settings in the database and config file.  The only difference between the two packages is the packaging (the code dosnt change based on distro or anything).

               

              Again, Spark will not prompt for any certs/keystores if the server dosnt say which CA's are acceptable. Thats not a bug in Spark (what is arguably a bug is not giving a useful message to the user, however, but thats different)

                • Daniel Bronze 19 posts since
                  Mar 26, 2009
                  Currently Being Moderated
                  Apr 30, 2009 3:40 AM (in response to vargok)
                  Re: Openfire+Spark - Client X.509/PKI Certificate Support

                  Did anybody found something out? I'm still trying to fix this problem up. In case this will not work, does anybody have alternative ideas? I need to implement an encrpted and authenticated connection.

                   

                  Thanks in advance

                   

                  Daniel

                    • slushpupie KeyContributor 776 posts since
                      Jan 27, 2006

                      Ive not done any work on Spark/Smack in quite a while, and others have.  Its entirely possible the changes others have made broke the callback handling.  Ive been pretty busy lately so I dont know if Ill have time to look at it soon either. As far as SSL vs TLS goes, its the same path through the code as far as the SSL negotiation is, so there should be no difference. 

                       

                      The difference between a JKS and a PKCS11 keystore to the client is none, since its using the pure keystore interface.  The only real difference is where you get it from.

                       

                      Sorry Ive not been much help lately, I just have not had the time to work on any of this.

        • Daniel Bronze 19 posts since
          Mar 26, 2009

          Well this isn't the best solution, but at least it's kind of working.

          @slushpupie: Is this Problem scheduled to be fixed?

           

          Daniel

          • slushpupie KeyContributor 776 posts since
            Jan 27, 2006

            I doubt any of the other people with svn access understand this well enough to fix it (anyone who does dev work in PKI certainly understands how rare it is) and Im stretched a bit thin with other commitments at the moment. So no, its not really in a timeline anywhere.  Ill try to get on the community group chat today- perhaps we can all discuss it then.

              • Daniel Bronze 19 posts since
                Mar 26, 2009

                Okay, im getting closer. Your solution seems to work. The only thing which prevents me from connection to the Server is this error:

                 

                2009.05.07 10:30:18 Closing session due to exception: (SOCKET, R: /192.168.0.135:2003, L: /192.168.0.135:5222, S: 0.0.0.0/0.0.0.0:5222)                 
                org.apache.mina.filter.codec.ProtocolDecoderException: java.lang.Exception: Disallowed character (Hexdump: 80 62 01 03 01 00 39 00 00 00 20 00 00 04 01 00 80 00 00 05 00 00 2F 00 00 33 00 00 32 00 00 0A 07 00 C0 00 00 16 00 00 13 00 00 09 06 00 40 00 00 15 00 00 12 00 00 03 02 00 80 00 00 08 00 00 14 00 00 11 4A 02 9C 1A 68 7A 1F 9D 31 7C DC DD 0D FF FF 1E E5 52 5F 47 0A 50 7F 13 E5 60 84 F4 EA 0E 19 52)

                 

                This occures while TLS handshaking. i think theres someting wrong with my certificates but i dont know what, any idea? is the character '-' disallowed in certificate names?

                 

                Daniel

        • Daniel Bronze 19 posts since
          Mar 26, 2009
          Currently Being Moderated
          May 11, 2009 7:34 AM (in response to vargok)
          Re: Openfire+Spark - Client X.509/PKI Certificate Support

          Okay, Im still stuck. Ive created those openssl certificates once again using only letters. Imported them into the keystore and truststore of the client with all the same password. The same on the server side. Smack api is fixed with the diff patches which where posted above and repacked with ant.

          Ive tried to connect on port 5222 with config.setSocketFactory(SSLSocketFactory.getDefault()); and without it. In both configurations I get "Closing session due to excpetion"and java.lang.Exception: Disallowed character. Openssl client test says that there still arent any certificates offered.

          openssl s_client -prexit -connect  localhost:5222
          Loading 'screen' into random state - done
          CONNECTED(00000778)
          3440:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:.\ssl\s23_lib.c:188:
          ---
          no peer certificate available
          ---
          No client certificate CA names sent
          ---
          SSL handshake has read 0 bytes and written 124 bytes
          ---
          New, (NONE), Cipher is (NONE)
          Compression: NONE
          Expansion: NONE
          ---

          Is this an indication for this problem?

           

          Port 5223 offers certificates, but im not able to connect.

          With config.setSocketFactory(SSLSocketFactory.getDefault()); i get sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target and without it get javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

          Im grateful for any help

           

          EDIT: I found out that, when using config.setSocketFactory(SSLSocketFactory.getDefault()); on port 5223 Smack uses the cacerts keystore in the jre folder. If I add my root certificate into that keystore i get javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: Netscape cert type does not permit use for SSL server.

           

          EDIT2: Ive removed all Netscape comments an attributes from those openssl certificates to fix the "Netscape cert type does not permit use for SSL server" problem, but Im ending up in a "null certificate chain". So, back to the beginning. Im getting mad

            • Daniel Bronze 19 posts since
              Mar 26, 2009
              Currently Being Moderated
              May 12, 2009 1:41 AM (in response to vargok)
              Re: Openfire+Spark - Client X.509/PKI Certificate Support

              Client.truststore has default settings, I didnt change them. Im using Windows, so the server is running with my user which is administrator. I think if there would be no access to the client.trusstore, an error would be listed in the debug log.Obviously on Port 5223 my certificates are offered, so I think openfire is able to access the client.truststore.

              The CallbackHandler, which you are using in your client code, which package is it from? If I import the class which eclipse proposes to me(javax.security.auth.callback.CallbackHandler). It cant be instantiated because it is an Interface. Did you write a callbackhandler by yourself?

               

              EDIT: Obviousely connection via port 5223 is working. Setting those systems propertys made my day But I want to find out, why there are no certificates offerd on port 5222

        • slushpupie KeyContributor 776 posts since
          Jan 27, 2006
          Currently Being Moderated
          May 27, 2009 9:52 AM (in response to vargok)
          Re: Openfire+Spark - Client X.509/PKI Certificate Support

          Callback handler patch has been applied to trunk.

  • Indiket Bronze 1 posts since
    May 25, 2009
    Currently Being Moderated
    May 27, 2009 4:39 AM (in response to vargok)
    Re: Openfire+Spark - Client X.509/PKI Certificate Support

    Hello!

    First of all, let me introduce myself. I'm a student at the University of Girona (Catalonia, Spain) and doing my master thesis about an application that uses XMPP. So, recently my tutor told me that it would be great to implement an authentification using X.509, and that's why I have ended in this post.

     

    Well, I follow this topic trying to make it work, but I'm having the similar problems that are describing some posts earlier.

    Problems (i'm using 5222 TLS port):

    - At client side the error is: "handshake message sequence violation,2" if i'm not using setSocketFactory.

    - Using socketfactory: SocketException: coonection is closed ... Remote host closed connection during handshake.

     

    - At server side:     Warn: java.lang.Exception: Disallowed character

                                Debug: SSL Handshake failed .... SSLHandshakeException: null cert chain

     

    If I use 5223 on Debug: SSLException: Unrecognized SSL message, plaintext connection?

     

    There are a few things that I'm not sure if I had done ok, so let me explain what I'm using:

    - I followed the instructions of the first posts (create the system preferences in OpenFire).

    - I'm using the SMACK API 3.1.0 and patched with the last patch of vargok.

    - The callback is called but before doing any SSL connection. Normal?

    - I'm not sure if the client is accessing to the client certificate...

         - On server side, I added my CA to client.trustore (it appears as trustedCertEntry), in trustore also. The private key of the server was added in keystore (and it appears as a PrivateKeyEntry).

         - Openfire complains about pending validation of my private key, althought it was validated by my CA. Does it affect it?

         - On client side, I created a keystore and truststore and added the client cert and the CA. But when I checked in keytool about keystore file, it shows the client cert but it says: trustedCertEntry. Is that normal?

     

         - When I do a openssl s_client on 5223, it prints the next output:

    xavi@songohan:~/openfire/resources/security$ openssl s_client -prexit -connect localhost:5223CONNECTED(00000003)
    depth=0 /C=ES/ST=Catalunya/L=Girona/O=Universitat de Girona/OU=Broadband Communications and Distributed Systems/CN=songohan.udg.edu/emailAddress=contacte@triem.org
    verify error:num=18:self signed certificate
    verify return:1
    depth=0 /C=ES/ST=Catalunya/L=Girona/O=Universitat de Girona/OU=Broadband Communications and Distributed Systems/CN=songohan.udg.edu/emailAddress=contacte@triem.org
    verify error:num=7:certificate signature failure
    verify return:1
    depth=0 /C=ES/ST=Catalunya/L=Girona/O=Universitat de Girona/OU=Broadband Communications and Distributed Systems/CN=songohan.udg.edu/emailAddress=contacte@triem.org
    verify return:1

     

    Why it gives me three outputs?

     

    I think that it would be very helpful if anyone could attach a fake CA, Server Key and Client Key that works with X.509 auth on OpenFire (or also, a good tutorial to generate it).

     

    Finally, I put some of my code that I'm using to connect in case anything is wrong.

     

    ConnectionConfiguration cc = new ConnectionConfiguration(server,port,server);

    String KEYSTORE_PATH=... //absolute path to the keystore file

    String KEYSTORE_PASSWORD="changeit"

    String TRUSTSTORE_PATH=...

    String TRUSTSTORE_PASSWORD="changeit"

     

    cc.setKeystorePath(KEYSTORE_PATH);

    cc.setKeystoreType("jks");

     

    cc.setTruststorePath(TRUSTSTORE_PATH);

    cc.setTruststoreType("jks");

    cc.setTruststorePassword(TRUSTSTORE_PASSWORD);

     

    cc.setCallbackHandler(new myCallbackHandler()); //I'm using vargok callback

    //cc.setSocketFactory(SSLSocketFactory.getDefault());

    XMPPConnection connection = new XMPPConnection(cc);

     

    //System.setProperty("javax.net.debug","ALL");

     

    SASLAuthentication.supportSASLMechanism("PLAIN",0);

     

    connection.connect();

     

    connection.login(username,password,resource);  //hope to remove if it works!

     

    I'm willing to help as much as possible in this aspect. If needed, I'll join the next chat and be avaiable to do as many tests I can. Please, help me

    Thanks for advance!

     

    ----------------------------------------------------------

    Update: Yay! Finally I made it work! As I suspected, the problem is that my client didn't get the client key, so there was no avaiable keys and that's why the server closed the connections.

     

    The openssl output is ok, and the pending validation is not a problem. My real problem is in the client keystore.

     

    There is a little problem adding certs to the keystore using keytool. At the following webpage it explains this problem and how to solve it:

    http://www.agentbob.info/agentbob/79-AB.html

     

    To check that the client cert was insered correctly, when you do a :

    >>keytool -list -keystore keystore

    And it should appear as a KeyEntry instead of CertEntry

     

    After do that, all started to work magicly. The callback detected the client cert and so on

    If I try to use the default SocketFactory, it seems that it doesn't work.

     

    One last question: I'm using EXTERNAL auth and works, but is it necessary that the client executes the login method? (e.g. login("","")).

     

    So, here is the needed code to make it work for me:

    ConnectionConfiguration cc = new ConnectionConfiguration(server, port, server);
    cc.setKeystorePath("....");
    cc.setKeystoreType("jks"); //not needed, by default jks
    cc.setCallbackHandler(new myCallbackHandler());
    connection = new XMPPConnection(cc);

     

    //System.setProperty("javax.net.debug","ALL");

     

    SASLAuthentication.supportSASLMechanism("PLAIN", 2);
    SASLAuthentication.supportSASLMechanism("DIGEST-MD5", 1);
    SASLAuthentication.supportSASLMechanism("EXTERNAL", 0);

     

    connection.connect();

    connection.login("", "");

More Like This

  • Retrieving data ...

Bookmarked By (1)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points