Transport agent cannot find a certificate in local store

403 views Asked by At

The error is as following:

The transport process failed during message processing with the following call stack: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Cannot find the X.509 certificate using the following search criteria: StoreName 'My', StoreLocation 'CurrentUser', FindType 'FindByThumbprint', FindValue 'c454f0a61e4cb0ed77ae87ede892ff09e584eca2'.
   at System.ServiceModel.Security.SecurityUtils.GetCertificateFromStoreCore(StoreName storeName, StoreLocation storeLocation, X509FindType findType, Object findValue, EndpointAddress target, Boolean throwIfMultipleOrNoMatch)
   at System.ServiceModel.Security.SecurityUtils.GetCertificateFromStore(StoreName storeName, StoreLocation storeLocation, X509FindType findType, Object findValue, EndpointAddress target)
   at System.ServiceModel.Security.X509CertificateInitiatorClientCredential.SetCertificate(StoreLocation storeLocation, StoreName storeName, X509FindType findType, Object findValue)
   at Zeva.WCFHelper.ClientBaseWrapper`1..ctor(BindingSettings bindingSettings, String address, String spnIdentity, Maybe`1 certificateAuthenticationSettings)
   --- End of inner exception stack trace ---
   at SampleCompany.TransportAgent.ModificationAgent.OnEndOfDataHandler(ReceiveMessageEventSource source, EndOfDataEventArgs eodArgs) in C:\Users\rani\Source\Workspaces\Mobility\Dev\SampleCompany\SampleCompany.TransportAgent\ModificationAgent.cs:line 48
   at Microsoft.Exchange.Data.Transport.Smtp.SmtpReceiveAgent.Invoke(String eventTopic, Object source, Object e)
   at Microsoft.Exchange.Data.Transport.Internal.MExRuntime.Dispatcher.Invoke(MExSession session)
   at Microsoft.Exchange.Data.Transport.Internal.MExRuntime.MExSession.AsyncInvoke(Object state)
   at Microsoft.Exchange.Data.Transport.Internal.MExRuntime.MExSession.BeginInvoke(String topic, Object source, Object e, AsyncCallback callback, Object callbackState)
   at Microsoft.Exchange.Protocols.Smtp.BaseDataSmtpCommand.RaiseEODEvent(Object state)
   at Microsoft.Exchange.Protocols.Smtp.BaseDataSmtpCommand.OnEod(Boolean isAsync)
   at Microsoft.Exchange.Protocols.Smtp.BaseDataSmtpCommand.RawDataReceived(Byte[] data, Int32 offset, Int32 numBytes)
   at Microsoft.Exchange.Protocols.Smtp.SmtpInSession.ReadComplete(IAsyncResult asyncResult)
   at Microsoft.Exchange.Net.LazyAsyncResult.WorkerThreadComplete(Object state)
   at Microsoft.Exchange.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at Microsoft.Exchange.Net.LazyAsyncResult.ProtectedInvokeCallback(Object value, IntPtr userToken)
   at Microsoft.Exchange.Net.NetworkConnection.InvokeRecvCallback(LazyAsyncResultWithTimeout asyncResult, Object result)
   at Microsoft.Exchange.Net.NetworkConnection.ReadDataAvailable(IAsyncResult asyncResult)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Description: I am implementing a transport agent that do some modification emails, it is required that I call a WCF service that returns some data and based on that data I do the modification. the issue arises when calling the WCF service (which is very well tested and in use for production). apparently, the transport agent cannot find the certificates in the current user store.

What I have already tried: 1. install the certificate (pfx file) into current user account (logically this should not work as the current user for transport agent is Network service). 2. install for the local machine, also did not work. 3. install for the service account (Microsoft Exchange Transport), also did not find the certificate.

So my question is how to install certificates to be used by code within transport agents?

0

There are 0 answers