Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using MimeKit in an ASP.NET web service environment #285

Closed
kae36 opened this issue Mar 8, 2017 · 4 comments
Closed

Using MimeKit in an ASP.NET web service environment #285

kae36 opened this issue Mar 8, 2017 · 4 comments

Comments

@kae36
Copy link

kae36 commented Mar 8, 2017

I have an ASP.NET web app service running on IIS 8.5 and the service runs fine in my own testing environment as it stores its temporary data in a directory located in the C:\Users{USERNAME}\AppData\Roaming\Roaming\mimekit directory, but when run from an IIS environment the environment is locked down and errors are generated when MimeKit tries to store information in a temporary directory where it doesn't have access. The error received is below.

System.UnauthorizedAccessException: Access to the path 'Roaming\mimekit' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost) at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost) at MimeKit.Cryptography.DefaultSecureMimeContext..cctor().

Is there any way to direct MimeKit to a different area to store this temporary data so that it can be used in an IIS environment?

Added with Edit: The web application service only uses the MimeMessage signing and MailKits Sending methods. The web app service doesn't use the encryption and does not use any decryption or reading of the message.

jstedfast added a commit that referenced this issue Mar 8, 2017
@jstedfast
Copy link
Owner

Somehow DefaultSecureMimeContext is being used in some way which is cauing the .cctor to create that directory.

I've fixed it so it doesn't create the directory at all anymore (until/unless an instance of DefaultSecureMimeContext is created).

@kae36
Copy link
Author

kae36 commented Mar 8, 2017

I thought the DefaultSecureMimeContext was required for MimeKit to work and be able to sign messages?

I used the suggested MySecureMimeContext definition example from the MimeKit documentation and registered it using

CryptographyContext.Register (typeof (MySecureMimeContext));

@jstedfast
Copy link
Owner

Well, you can subclass one of the other SecureMimeContext types, but what you did is also fine - it's just that there was a bug in DefaultSecureMimeContext's static constructor which tried to create the default smime.db path when it should not have been doing that.

@jstedfast
Copy link
Owner

If you check out the latest source code and build it, you'll have a working MimeKit for your ASP.NET environment (or, at least unless there's some other problem).

I'll also try to publish a new nuget release by this weekend (likely will have a version of 1.12.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants