PrivateKey priKey, String profile) throws ClientException {
CertStore store = getCaCertificate(profile);
Capabilities caps = getCaCapabilities(profile);
CertStoreInspector certs = CertStoreInspector.getInstance(store);
X509Certificate recipientCertificate = certs.getRecipient();
PkcsPkiEnvelopeEncoder envEncoder = new PkcsPkiEnvelopeEncoder(
recipientCertificate, caps.getStrongestCipher());
String sigAlg = caps.getStrongestSignatureAlgorithm();
return new PkiMessageEncoder(priKey, identity, envEncoder, sigAlg);
}