[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-jce] Outlook problem with encrypted mails



Hi !
 
I've got the problem that I'm not able to read encrypted mails sent with Outlook2000
and I'm not able to read mails enrypted with IAIK_SMIMEv2.6
 
The certificates are known by both the java classes and Outlook 2000.
Outlook 2000 says "Your Digital ID can't be found in the underying Security System".
 
 
The Encryption method looks 
 
 public void encrypt(Part container, Multipart part)
 throws MessagingException, GeneralSecurityException
 {
  Message message = getMessage(container);
  Address[] addresses = message.getAllRecipients();
  String[] aliases;
  InternetAddress inetAddress;
  AlgorithmID alg;
  iaik.x509.X509Certificate x509;
  Certificate cert;
  int idx;
  if (debug_ ) System.out.println("Trying to encrypt the message");
  EncryptedContent ec = new EncryptedContent();
  // set type to enveloped data
  ec.setSMimeType();
  // add the content of that should be encrypted
  if (debug_) System.out.println("adding the content to the encrypted part");
  ec.setContent(part);
  // determine the recipient certs
  // certs only aliases are allowed
  // the certs must be valid, not revoked ...
  // only one alias per recipient should be returned
  aliases = getAliasFor(addresses, false, true, true);
  if (aliases.length != addresses.length )
  {
   // problem at least one Certificate could not be found
   // not all recipients will be able to decrypt the message
   throw new MessagingException("One or more recipient won't be able to decryt the message.");
  }
  System.out.println("found "+ aliases.length + "aliases");
  alg = getAlgorithmID();
  // set the encryption algorithm
  for ( idx = 0; idx < aliases.length; ++ idx)
  {
   System.out.println("trying to add recipient " + aliases[idx]);
   cert = edgeKeyStore_.getCertificate(aliases[idx]);
   x509 = SecurityUtil.convertX509Cert(cert);
   System.out.println( x509 != null ? x509.getClass().getName() : null );
   // Attention ! : Only RSA Encryption allowed with IAIK_SMIME 2.6
   // see EncryptedContent.addRecipient(X509Certificate, AlgorithmID )
   ec.addRecipient(x509, AlgorithmID.rsaEncryption );
  } /* end for */
  System.out.println ( (alg != null ?  alg.getName() : "null") + " keylength = " +  getEncryptionKeyLength()  );
  ec.setEncryptionAlgorithm(alg , getEncryptionKeyLength() );
  // add the part to the container
  message.setContent(ec, ec.getContentType());
  ec.setHeaders(message);
  return;
 }
Is there a solution for my problem ? Is there something wrong with my encryption method ?
 
thanks in advance
andi