code: public void checkServerTrusted( X509Certificate[] chain, String authType )
              throws CertificateException
      {
          X509Certificate certificate = chain[0];
  
          String cert = fingerprint( certificate );
  
          if ( this.fingerprint == null )
          {
              try
              {
                  saveTrustedHost( cert );
              }
              catch ( IOException e )
              {
                  throw new CertificateException( format(
                          "Failed to save the server ID and the certificate received from the server to file %s.\n" +
                          "Server ID: %s\nReceived cert:\n%s",
                          knownHosts.getAbsolutePath(), serverId, X509CertToString( cert ) ), e );
              }
          }
          else
          {
              if ( !this.fingerprint.equals( cert ) )
              {
                  throw new CertificateException( format(
                          "Unable to connect to neo4j at `%s`, because the certificate the server uses has changed. " +
                          "This is a security feature to protect against man-in-the-middle attacks.\n" +
                          "If you trust the certificate the server uses now, simply remove the line that starts with " +
                          "`%s` " +
                          "in the file `%s`.\n" +
                          "The old certificate saved in file is:\n%sThe New certificate received is:\n%s",
                          serverId, serverId, knownHosts.getAbsolutePath(),
                          X509CertToString( this.fingerprint ), X509CertToString( cert ) ) );
              }
          }
      }
docs: /*
  Trust the cert if it is seen first time for this server or it is the same with the one registered.