| Author | 
         | 
         
      
        
         
         robert.jarocki Newbie 
          
 
  Joined: 14 March 2019
 Online Status: Offline Posts: 3
          | 
        
         
          
           | Posted: 14 March 2019 at 10:14am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
We use MailBee.NET to send e-mails. Recently, we've tried to add signing emails with a certificate.
 We implemented the code using this link
 During the tests, it turned out that some mailboxes have a problem with SHA-1 and some of the mailboxes have problems with the certificate chain. We found a thread on the forum and we updated dll from this post
 
 
 So our current version of MailBee.NET is MailBee.NET 11.2.0.611 and the email signing code looks like this:
 
 Certificate cert = GetCertificate(eMail);
 if (cert != null)
 {
      Smime secureMime = new Smime();
 
         Algorithm algrsha256 = Algorithm.CreateInstanceByOid("2.16.840.1.101.3.4.2.1");
         secureMime.HashAlgorithm = algrsha256;
 
         msg = secureMime.Sign(msg, cert);
 }
 
 
 And sometimes we get an exception when we try to use the Sign method:
 MailBee.Security.MailBeeCertificateException: CryptographicException occurred. InnerException message follows: the buffer supplied to a function was too small
  ---> System.Security.Cryptography.CryptographicException: the buffer supplied to a function was too small
 
    in System.Security.Cryptography.Pkcs.SignedCms.Sign(CmsSigner signer, Boolean silent)
    in System.Security.Cryptography.Pkcs.SignedCms.ComputeSignature(CmsSigner signer, Boolean silent)
    in MailBee.Security.Smime.a(Byte[] A_0, Certificate A_1, Certificate[] A_2, Boolean A_3)
 
 
 Do you have an idea about what the error can be caused by?
 In addition at MailBee.NET version 11.2.0.590 this problem did not occur. Only there was a problem with the certification chain and this version can not be used.
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Alex AfterLogic Support 
          
  
  Joined: 19 November 2003
 Online Status: Offline Posts: 2207
          | 
        
         
          
           | Posted: 15 March 2019 at 3:41am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
What is the OS version and .NET version/edition? Looks like an internal bug in .NET:
 
 https://github.com/dotnet/corefx/issues/7812
 
 Looks like it can be probably be fixed with OS or .NET update.
 
 Regards,
 Alex
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         robert.jarocki Newbie 
          
 
  Joined: 14 March 2019
 Online Status: Offline Posts: 3
          | 
        
         
          
           | Posted: 15 March 2019 at 7:59am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Hello,
 Thanks for update. We are using two different machines. Both of them:
 OS Name: Microsoft Windows Server 2012 R2 Standard
 OS Version: 6.3.9600 N/A Build 9600
 
 .NET Framework 4.7.2
 
 Update don't resolve this problem. Any other ideas?
 
 Best Regards,
 Robert Jarocki
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Alex AfterLogic Support 
          
  
  Joined: 19 November 2003
 Online Status: Offline Posts: 2207
          | 
        
         
          
           | Posted: 15 March 2019 at 9:24am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Here they say (from what I see) you'll need to upgrade to Server 2016 (no info when they fix this for older Windows versions):
 
 https://github.com/dotnet/corefx/issues/31611
 
 Old version of MailBee.NET wasn't affected probably because it didn't use signature time-stamping (which was no good).
 
 Regards,
 Alex
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         Alex AfterLogic Support 
          
  
  Joined: 19 November 2003
 Online Status: Offline Posts: 2207
          | 
        
         
          
           | Posted: 15 March 2019 at 9:36am | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
As a workaround, they suggest disabling some cipher suits in Windows:
 
 https://github.com/dotnet/corefx/issues/7812#issuecomment-305848835
 
 Regards,
 Alex
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   | 
      
        
         
         robert.jarocki Newbie 
          
 
  Joined: 14 March 2019
 Online Status: Offline Posts: 3
          | 
        
         
          
           | Posted: 15 March 2019 at 1:30pm | IP Logged
		     | 
                    
            		  
           | 
           
          
           
  | 
           
          
Hi,
 We will check it and I'll back to you soon.
         | 
       
       
        | Back to Top | 
         
          
         | 
       
       
       
        |   |