WCF 서비스를 자체 호스팅하는 .NET 3.5 Framework를 사용하여 Windows Forms 응용 프로그램을 만들었습니다. 서비스 &은 자체적으로 올바르게 작동합니다.SignedXml.ComputeSignature를 사용하여 구성 파일에 서명을 추가 한 후 "Unrecognized configuration section"
주소가 &이고 app.config 파일에서 바인딩 정보에 액세스 할 염려가 있으니 System.Security.Cryptography.Xml.SignedXml.ComputeSignature를 사용하여 디지털 서명을 추가하기로했습니다. 그런 다음 app.config에 서명을 추가하고 저장했습니다. 그러면 app.config 파일의 구성 노드의 최종 하위 요소 인 app.config에 Signature 요소가 만들어집니다.
서비스를 시작하기 전에 서명을 확인하는 기능이 추가되었습니다. 응용 프로그램은 제대로 서명을 확인하지만, 다음 서비스를 시작하려고 할 때, 다음과 같은 중첩 오류가 발생합니다 :
- 'System.ServiceModel.DiagnosticUtility'의 형식 이니셜 라이저에서 예외를 Throw했습니다.
2.Configuration 시스템은
3.Unrecognized 구성 섹션 서명을 초기화하지 못했습니다.
어디에서 Signature 요소를 app.config에 두어도 상관 없습니다. 서명은 항상 올바르게 확인되며 서비스는 항상 인식 할 수없는 구성 섹션에 대한 불만을 터트립니다. app.config의 Signature 요소와 코드의 서명 체크를 주석 처리하면 서비스가 아무 문제없이 다시 시작됩니다.
왜 서비스에서 이러한 오류가 발생하며이를 해결하려면 어떻게해야합니까? 여기
은 편집 됨 응용 프로그램 이름 & URL을와의 app.config입니다 :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="MyApp.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyAppServicePortBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myappurl/MyService" binding="basicHttpBinding" bindingConfiguration="MyAppServicePortBinding" contract="MyAppService" name="MyAppServicePort" />
</client>
<services>
<service name="MyApp.MyService" behaviorConfiguration="MyAppServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="http://mylocalservice:8080/LocalService" />
</baseAddresses>
</host>
<!-- this endpoint is exposed at the base address provided by host -->
<endpoint address="" binding="wsHttpBinding" contract="MyApp.IServiceInit" bindingNamespace="http://mylocalservice:8080/LocalService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyAppServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<applicationSettings>
<MyApp.My.MySettings>
<setting name="DefaultEntryType" serializeAs="String">
<value>M</value>
</setting>
<setting name="CardTypes" serializeAs="String">
<value>1111</value>
</setting>
<setting name="Freq" serializeAs="String">
<value>120000</value>
</setting>
</MyApp.My.MySettings>
</applicationSettings>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>jJYnz3j6LgxqdcUgvNSGNmJVum4=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>czpn/uA31kMSoGFk2hi3SCYky6YM6/MjBT3lpMn7wluCjeFIFj0vJJZVI9ueQQn/RglFi8RIfAyov3rDwiS+pP/4b1Yh8KqNOftHMH9pC+CFsMHMQnIoPHyXVrFLpuU6rzjACdUky4zuB7I7Q5AHf1CF8F9PSEgIxiQ4gHgPhJCLujl6wvsMg3rXDHazRQ2Curj94iKUIsKo50X1dJxER1oWOB9g6QgzqsXTOmUkgGOygJrnrn1WQJ0UbWAvHHXIPZdD6jOL24vqhOYm55+b6hlkWdIvEvLBPVMtv2V8oQqxBpWRDh8ovMn4LQdgcFOpa/vG3ISXGp2oRzsCEpaxCQ==</SignatureValue>
</Signature>
</configuration>
아직까지는 서비스에서 이러한 오류가 발생하지 않았습니다. 구성 파일의 섹션이 알려지지 않았기 때문에 .NET 구성 시스템에서 예외가 발생했습니다. –
John - 설명해 주셔서 감사합니다. 서비스가 시작하려고 시도 할 때 오류가 발생했기 때문에이 두 가지를 연관 시켰지만 서비스 자체가 근본 원인이라고 이해하지 못했습니다. –