【发布时间】:2017-03-13 01:58:32
【问题描述】:
安装库 MailKit 并调用 new SmtpClient().ConnectAsync(_settings.Server, _settings.Port, _settings.SSL); 后,我收到此错误:
拒绝访问路径“/var/www/.dotnet/corefx/cryptography/crls”。
顺便说一句,我的项目位于 /media/ProjectName。
我尝试执行此操作:sudo chmod -R 755 /var 但出现权限错误。
这里是堆栈跟踪:
在 System.IO.UnixFileSystem.CreateDirectory(String fullPath)↵ 在 System.IO.Directory.CreateDirectory(String path)↵ 在 Internal.Cryptography.Pal.CrlCache.GetCachedCrlPath(X509Certificate2 cert, Boolean mkDir)↵ 在内部。 Cryptography.Pal.CrlCache.DownloadAndAddCrl(X509Certificate2 证书,SafeX509StoreHandle 存储,TimeSpan& 剩余下载时间)↵ 在 Internal.Cryptography.Pal.CrlCache.AddCrlForCertificate(X509Certificate2 证书,SafeX509StoreHandle 存储,X509RevocationMode revocationMode,DateTime 验证时间,时间跨度和剩余下载时间)↵ Pal.OpenSslX509ChainProcessor.BuildChain(X509Certificate2 叶, HashSet
1 candidates, HashSet1 已下载, HashSet1 systemTrusted, OidCollection applicationPolicy, OidCollection certificatePolicy, X509RevocationMode revocationMode, X509RevocationFlag revocationFlag, DateTime verificationTime, TimeSpan& remainingDownloadTime)↵ at Internal.Cryptography.Pal.ChainPal.BuildChain(Boolean useMachineContext, ICertificatePal cert, X509Certificate2Collection extraStore, OidCollection applicationPolicy, OidCollection certificatePolicy, X509RevocationMode revocationMode, X509RevocationFlag revocationFlag, DateTime verificationTime, TimeSpan timeout)↵ at System.Security.Cryptography.X509Certificates.X509Chain.Build(X509Certificate2 certificate)↵ at System.Net.Security.CertificateValidation.BuildChainAndVerifyProperties(X509Chain chain, X509Certificate2 remoteCertificate, Boolean checkCertName, String hostName)↵ at System.Net.Security.SecureChannel.VerifyRemoteCertificate(RemoteCertValidationCallback remoteCertValidationCallback)↵ at System.Net.Security.SslState.CompleteHandshake()↵ at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)↵ at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)↵ at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)↵ at System.Net.Security.SslState.ReadFrameCallback(AsyncProtocolRequest asyncRequest)↵--- End of stack trace from previous location where exception was thrown ---↵ at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()↵ at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)↵ at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)↵ at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)↵ at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task`1 promise, Boolean requiresSynchronization)↵--- 堆栈跟踪结束从先前引发异常的位置 ---↵ 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)↵ 在 System.Runtime。 CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)↵ 在 MailKit.Net.Smtp.SmtpClient.Connect(String host, Int32 port, SecureSocketOptions options, CancellationToken cancelToken)↵ 在 MailKit.MailService.c__DisplayClass41_0.b__0()↵ 在 System。 Threading.Tasks.Task.Execute()↵--- 从先前抛出异常的位置结束堆栈跟踪 ---↵ 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)↵ 在 System.Runtime.CompilerServices。 TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)↵ 在 MyProject.Services.MessageService.d__4.MoveNext()↵--- 堆栈跟踪从先前抛出异常的位置结束---↵ 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess( Task task)↵ 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)↵ 在 MyProject.Services.MessageService.d__5.MoveNext()
【问题讨论】:
-
调用堆栈表明代码正在尝试构建和访问证书缓存。您可以手动创建目录并授予必要的权限。不要修改 /var 顶级目录,因为那太疯狂了。
-
谢谢你,@LexLi。我应该在写这篇文章之前创建这个目录。它有效!
标签: asp.net asp.net-core ubuntu-14.04 hosting