code: public static List<X509Certificate> decodeCertificates(byte[] certificateBytes) throws UaException {
          Preconditions.checkNotNull(certificateBytes, "certificateBytes cannot be null");
  
          CertificateFactory factory;
  
          try {
              factory = CertificateFactory.getInstance("X.509");
          } catch (CertificateException e) {
              throw new UaException(StatusCodes.Bad_InternalError, e);
          }
  
          try {
              Collection<? extends Certificate> certificates =
                      factory.generateCertificates(new ByteArrayInputStream(certificateBytes));
  
              return certificates.stream()
                      .map(X509Certificate.class::cast)
                      .collect(Collectors.toList());
          } catch (CertificateException e) {
              throw new UaException(StatusCodes.Bad_CertificateInvalid, e);
          }
      }
docs: Decode either a sequence of DER-encoded X.509 certificates or a PKCS#7 certificate chain.
  
  @param certificateBytes the byte[] to decode from.
  @return a {@link List} of certificates deocded from {@code certificateBytes}.
  @throws UaException if decoding fails.