code: public static void saveX509Cert( String certStr, File certFile ) throws IOException
      {
          try ( BufferedWriter writer = new BufferedWriter( new FileWriter( certFile ) ) )
          {
              writer.write( BEGIN_CERT );
              writer.newLine();
  
              writer.write( certStr );
              writer.newLine();
  
              writer.write( END_CERT );
              writer.newLine();
          }
      }
docs: Save a certificate to a file in base 64 binary format with BEGIN and END strings
  @param certStr
  @param certFile
  @throws IOException