4

In my project i am using ACS SAML Security. Here we need to provide the client certificate and server private key to invoke the service, these can be set in a webconfig file. The web service Running in Azure its fine, but i need to run the Web service in our Remote Server. So i published the project in IIS. But i am getting exception..

An internal error occurred.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: An internal error occurred.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[CryptographicException: An internal error occurred.]
   System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) +41
   System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx) +0
   System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags) +372
   System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password) +157
   ClassicMDM.WCFServiceWebRole.MyServiceHostfactory.GetServiceCertificateWithPrivateKey() in F:\Core\_Core\Class\trunk\test.WCFServiceWebRole\testWebService.svc.cs:172
   test.WCFServiceWebRole.MyServiceHostfactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) in F:\Core\_Core\Class\trunk\test.WCFServiceWebRole\testWebService.svc.cs:140
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +530
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1413
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +50
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172

[ServiceActivationException: The service '/testwebserviceINT/testWebService.svc' cannot be activated due to an exception during compilation.  The exception message is: An internal error occurred]
   System.Runtime.AsyncResult.End(IAsyncResult result) +901424
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178702
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136

So please help me..how can solve the issue?

user10489
  • 255
  • 2
  • 6
  • 17
  • 2
    Can't help without the code that throws this exception. – PhonicUK Nov 06 '12 at 11:44
  • The Acs SAML secure service, successfully running on Azure.. But i need to work in IIS as well. So i want change anything in IIS server settings? like the account may be missing some permissions? – user10489 Nov 06 '12 at 11:53
  • If this isn't occurring in code you've written then you're posting in the wrong place. If it is in code you've written, you'll need to post some source for anyone to be able to help. – PhonicUK Nov 06 '12 at 11:58
  • The service '/icmdmmultiwebserviceINT/CMDMCustomerWebService.svc' cannot be activated due to an exception during compilation... – m4ngl3r Nov 06 '12 at 12:03
  • 2
    What is the version of IIS you are using? did you allow permission for the App Pool Identity to access the certificate in the certificate store? or if its a physical path, ensure the app pool identity has enough permission to read the certificate file. – Ramesh Nov 06 '12 at 12:22
  • @Ramesh:I am using IIS6.0 and windows server2008 R2....How can i allow permission for the APP Pool identity to access the certificate? please give me any link. – user10489 Nov 06 '12 at 12:35
  • I believe Windows server 2008 R2 comes with IIS 7.5. Anyways is the certificate file stored in the hard disk or in certificate store? – Ramesh Nov 06 '12 at 12:41
  • @Ramesh: The certificates stored under the bin folder in IIS web-root. If i call the same web service on Azure, it seems to work. But when i call the same service in IIS, its not working. – user10489 Nov 08 '12 at 10:19
  • Seems to be a duplicate. [See an answer here.][1] [1]: http://stackoverflow.com/questions/1345262/an-internal-error-occurred-when-loading-pfx-file-with-x509certificate2 – Dror May 30 '13 at 21:01

0 Answers0