code: @Sensitive
      public static byte[] encodeCertChain(Codec codec, @Sensitive X509Certificate[] certificateChain) {
          byte[] result = null;
  
          try {
              if (certificateChain != null) {
                  List<X509Certificate> certList = getCertChainAsListWithoutDuplicates(certificateChain);
  
                  CertificateFactory cfx = CertificateFactory.getInstance("X.509");
                  CertPath certPath = cfx.generateCertPath(certList);
  
                  Any any = ORB.init().create_any();
                  org.omg.CSI.X509CertificateChainHelper.insert(any, certPath.getEncoded());
                  result = codec.encode_value(any);
              }
          } catch (Exception e) {
              // do nothing, return null
          }
          return result;
      }
docs: Encode an X509 certificate chain.
  This logic was brought from tWAS' SessionEntry.convertCertChainToBytes to maintain compatibility.
  
  @param codec The codec to do the encoding of the Any.
  @param certificateChain The X509 certificate chain to encode.
  @return the codec encoded X509 certificate chain.