code: @SuppressWarnings("unchecked")
      @Sensitive
      public static X509Certificate[] decodeCertChain(Codec codec, @Sensitive byte[] encodedCertChain) throws SASException {
          X509Certificate[] certificateChain = null;
  
          try {
              Any any = codec.decode_value(encodedCertChain, X509CertificateChainHelper.type());
              byte[] decodedCertificateChain = X509CertificateChainHelper.extract(any);
  
              CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
              ByteArrayInputStream bais = new ByteArrayInputStream(decodedCertificateChain);
              CertPath certPath = certificateFactory.generateCertPath(bais);
              List<X509Certificate> certificates = (List<X509Certificate>) certPath.getCertificates();
  
              certificateChain = new X509Certificate[certificates.size()];
              for (int i = 0; i < certificates.size(); i++) {
                  certificateChain[i] = certificates.get(i);
              }
          } catch (Exception e) {
              throw new SASException(1, e);
          }
          return certificateChain;
      }
docs: Decode an X509 certificate chain.
  
  @param codec The codec to do the decoding of the Any.
  @param encodedCertChain The codec encoded byte[] containing the X509 certificate chain.
  @return the X509 certificate chain
  @throws SASException