title: Java ftps connection, TrustManager explaination (using filezilla server)
body: <p>I have written a program (obviously COPIED from the net, and modified it little according to my needs!) for file download/upload using apache ftp api and by creating a local server using Filezilla server.
  <strong>Everything is working FINE</strong>. The problem is I didn't get the part where we have to create a trust manager.</p>
  
  <p>Code:</p>
  
  <pre><code>FTPSClient ftpsClient= null;
  SSLContext sslContext = SSLContext.getInstance(protocol);
  TrustManager tm = new X509TrustManager() {
      public X509Certificate[] getAcceptedIssuers() {
          System.out.println("getAcceptedIssuers------");
          return null;
      }
  
      @Override
      public void checkClientTrusted(X509Certificate[] chain,
              String authType) throws CertificateException {
          // TODO Auto-generated method stub
          System.out.println("checkClientTrusted------");
      }
  
      @Override
      public void checkServerTrusted(X509Certificate[] chain,
              String authType) throws CertificateException {
          // TODO Auto-generated method stub
          System.out.println("checkServerTrusted------");
      }
  };
  
      sslContext.init(null, new TrustManager[] { tm }, null);//new SecureRandom());
      ftpsClient = new FTPSClient(true, sslContext);
  </code></pre>
  
  <p><strong>public X509Certificate[] getAcceptedIssuers()</strong> this method according to the documentation returns <strong>the list of certificate issuer authorities which are trusted for authentication of peers</strong>. But here in the code, the method is returning null.</p>
  
  <p>Also while setting the <strong>configuration for ftps</strong> in the Filezilla Server, I had to create a certificate.</p>
  
  <p>Seeing all this I didn't get why the certificate  was created as we are not <strong>passing or returning</strong> the certificate. Or does the server or library handles it internally. Can someone explain me thoroughly about this issue.</p>