/**
   * Add a recipient based on the passed in certificate's public key and its issuer and serial
   * number.
   *
   * @param recipientCert recipient's certificate
   * @return the current instance.
   * @throws CertificateEncodingException if the necessary data cannot be extracted from the
   *     certificate.
   */
  public JceKeyAgreeRecipientInfoGenerator addRecipient(X509Certificate recipientCert)
      throws CertificateEncodingException {
    recipientIDs.add(
        new KeyAgreeRecipientIdentifier(CMSUtils.getIssuerAndSerialNumber(recipientCert)));
    recipientKeys.add(recipientCert.getPublicKey());

    return this;
  }