protected static byte[] getCertificateBytes() {
    if (certificateBytes == null) {
      InputStream certifacteStream = getCertificateStream();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

      byte[] buffer = new byte[4096];

      try {
        int bytesRead = 0;
        while ((bytesRead = certifacteStream.read(buffer, 0, buffer.length)) != -1) {
          outputStream.write(buffer, 0, bytesRead);
        }
      } catch (IOException e) {
        Logger.getLogger(Configuration.class.getCanonicalName())
            .log(Level.SEVERE, "Error reading the certificate", e);
      }

      certificateBytes = outputStream.toByteArray();
    }
    return certificateBytes;
  }