|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Encrypt Email with Certificate Natively in .NetDim objMail As IMailSender = New MailSender Dim strEmailAddress As String objMail.Username = "xxx" objMail.Password = "xxx" objMail.Host = "xxx" objMail.Subject = subject objMail.From = replyTo objMail.FromName = replyTo For Each strEmailAddress In recipientsCleanList objMail.AddAddress(strEmailAddress, Nothing) Next objMail.IsHTML = 1 objMail.Body = strEmail.ToString Dim objCM As ICryptoManager = New CryptoManager Dim objContext As ICryptoContext = objCM.OpenContext("", 1, Nothing) Dim strPath As String = HttpContext.Current.Server.MapPath("secureemail.cer") Dim objRecipientCert As ICryptoCert = objCM.ImportCertFromFile(strPath) Dim objMsg As ICryptoMessage = objContext.CreateMessage(1) objMsg.AddRecipientCert(objRecipientCert) objMail.SendEncrypted(objMsg) Unfortunately I am using a shared hosting environment whic is set on "Medium Trust" which means I can't run the code. Can anyone give me an example of how to do the same thing natively in .Net. Thanks, Josh Hi,
I don't work on ASP but it seems to be near VB.NET (lol). You can't directly do the Encryption of Mail message (following S/MIME RFCs), in ..NET Framework 2.0. The reason is that the SmtpClient.Send method doesn't allow MIME Headers overwriting for the Content-Type that should be "application/pkcs7-mime; smime-type=signed-data; name="smime.p7m" by his own one (content-type: text/plain; charset=us-ascii). I had discussion with Fabrizio on this forum and privately, and a solution could be to implement an SMTP client on your own ;-( which means a lot of work (SMTP over SSL, SMTP authentication...). There are also informations on MS Connect website (VB and .NET section searching S/MIME headers or SMTPClient). Another way is to use CAPICOM.DLL and CDOMessage object but it is not 100% .NET Framework. I hope i have helped you Sorry my poor english Bye j***@youinspire.me.uk a écrit : Show quoteHide quote > I wrote the following code using the ASPEncrypt .Net Component: > > Dim objMail As IMailSender = New MailSender > Dim strEmailAddress As String > > objMail.Username = "xxx" > objMail.Password = "xxx" > > objMail.Host = "xxx" > objMail.Subject = subject > objMail.From = replyTo > objMail.FromName = replyTo > For Each strEmailAddress In recipientsCleanList > objMail.AddAddress(strEmailAddress, Nothing) > Next > objMail.IsHTML = 1 > objMail.Body = strEmail.ToString > > Dim objCM As ICryptoManager = New CryptoManager > Dim objContext As ICryptoContext = objCM.OpenContext("", 1, > Nothing) > Dim strPath As String = > HttpContext.Current.Server.MapPath("secureemail.cer") > Dim objRecipientCert As ICryptoCert = > objCM.ImportCertFromFile(strPath) > Dim objMsg As ICryptoMessage = objContext.CreateMessage(1) > objMsg.AddRecipientCert(objRecipientCert) > objMail.SendEncrypted(objMsg) > > Unfortunately I am using a shared hosting environment whic is set on > "Medium Trust" which means I can't run the code. Can anyone give me an > example of how to do the same thing natively in .Net. > > Thanks, > > Josh >
Encrypt data
Code Access Security for Windows Service System.Net.WebException: The remote server returned an error: (404) Not Found. Code signing - recommended cerificate provider? Help in signing SoapEnvelope using wse 3.0 Howto encrypt configuration sections using Enterprise Library ? Using Caspol to change Security Policy - Code Groups # different on different PC ??? Assembly Minimum Security Requirements .NET Applications in Linux Create X509 certificate in memory *without* makecert |
|||||||||||||||||||||||