code: public void save(OutputStream out) throws IOException {
  
          try {
              cred.save(out);
          } catch (CertificateEncodingException e) {
              throw new ChainedIOException(e.getMessage(), e);
          }
      }
docs: Saves the credential into a specified output stream. The self-signed certificates in the certificate
  chain will not be saved. The output stream should always be closed after calling this function.
  
  @param out
  the output stream to write the credential to.
  @exception IOException
  if any error occurred during saving.