Author |
|
raindm Groupie
Joined: 31 January 2008 Location: Israel
Online Status: Offline Posts: 44
|
Posted: 17 September 2009 at 1:25am | IP Logged
|
|
|
Hi
I have an issue with DomainKey.
When i use the byte method to save the domain key private key i get the error:
" Invalid cryptographic private key format. "
The code is:
//Read DomainKey Specifications
using (Stream stream = new FileStream(@Directory.GetCurrentDirectory() + "\\rsa.private", FileMode.Open, FileAccess.Read))
{
privateKey = new byte[stream.Length];
stream.Read(privateKey, 0, privateKey.Length);
}
DomainKeys dk = new DomainKeys();
objMailer.Message = dk.Sign(objMailer.Message, null, privateKey, "alfa");
However when i use direct read from file it does work using the code:
DomainKeys dk = new DomainKeys();
objMailer.Message = dk.Sign(objMailer.Message, null, Directory.GetCurrentDirectory() + "\\rsa.private", true, "alfa");
I do not want to read the file for every mail is send so i prefer to use the byte method for less H.D access.
If you know the reason for this it would greatly helpful.
Thank you,
Dror
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 21 September 2009 at 3:37am | IP Logged
|
|
|
The developers will investigate this.
|
Back to Top |
|
|
Andrew AfterLogic Support
Joined: 28 April 2006 Location: United States
Online Status: Offline Posts: 1189
|
Posted: 24 September 2009 at 2:39am | IP Logged
|
|
|
The issue happens because rsa.private file contains the key encoded along with special header, but Sign method expects pure key without irrelevant data.
In case when Sign loads the key from the file, it correctly processes the header and decodes the pure key.
However, the following call should do the trick for you:
Code:
objMailer.Message = dk.Sign(objMailer.Message, null, System.Text.Encoding.ASCII.GetString(privateKey), false, "alfa"); |
|
|
Best regards,
Andrew
|
Back to Top |
|
|
raindm Groupie
Joined: 31 January 2008 Location: Israel
Online Status: Offline Posts: 44
|
Posted: 27 September 2009 at 3:07am | IP Logged
|
|
|
thank you very much, it seems to work fine..!
|
Back to Top |
|
|