code: public static X509Certificate decodeCertificate(InputStream inputStream) throws UaException {
          Preconditions.checkNotNull(inputStream, "inputStream cannot be null");
  
          CertificateFactory factory;
  
          try {
              factory = CertificateFactory.getInstance("X.509");
          } catch (CertificateException e) {
              throw new UaException(StatusCodes.Bad_InternalError, e);
          }
  
          try {
              return (X509Certificate) factory.generateCertificate(inputStream);
          } catch (CertificateException | ClassCastException e) {
              throw new UaException(StatusCodes.Bad_CertificateInvalid, e);
          }
      }
docs: Decode a DER-encoded X.509 certificate.
  
  @param inputStream {@link InputStream} containing DER-encoded certificate bytes.
  @return an {@link X509Certificate}
  @throws UaException if decoding the certificate fails.