Шифрование Wcf/decrpytion с использованием как серверных, так и клиентских сертификатов
Hi, I have created a service where there would be a private cert on the server where i am hosting the service and the client will have public key of it. And the client would have a different private key where they will encrypt the message which they send to the endpoint i create and i have the public key for it which i will use to decrypt the message. What i have so far in the server config file. So this one takes care of the main private cert where the service will be hosted. I am not sure where/how to put the public key of the cert where client has/uses the private key to encrypt the message. What I have tried: <pre><?xml version="1.0"?> <configuration> <appSettings> </appSettings> <system.web> <httpRuntime maxRequestLength="2147483647"/> <compilation debug="false" strict="false" explicit="true" targetFramework="4.5.2"/> <pages controlRenderingCompatibilityVersion="4.0"/> <customErrors mode="Off"/> </system.web> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="basicHttpEndPointBinding"> <security mode="Message"> <message clientCredentialType="Certificate"/> </security> </binding> </basicHttpBinding> </bindings> <services> <service behaviorConfiguration="wcfJNet.ServiceBehavior" name="wcfJNetService"> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpEndPointBinding" contract="IJNetService"> <identity> <dns value="xxxxxx" /> </identity> </endpoint> </service> </services> <behaviors> <serviceBehaviors> <behavior name="wcfJNet.ServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> <serviceCredentials> <serviceCertificate findValue="0000xx000" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySerialNumber"/> <clientCertificate> <authentication certificateValidationMode="PeerOrChainTrust"/> </clientCertificate> </serviceCredentials> </behavior> </serviceBehaviors> </behaviors> <protocolMapping> <add binding="basicHttpsBinding" scheme="https"/> </protocolMapping> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <!-- To browse web app root directory during debugging, set the value below to true. Set to false before deployment to avoid disclosing web app folder information. --> <directoryBrowse enabled="true"/> </system.webServer> </configuration>
phil.o
Для шифрования сообщения используется открытый ключ, а не закрытый. Закрытый ключ используется для расшифровки зашифрованного сообщения.
Кратко:
используется закрытый ключ:
- подписывать сообщения
- для расшифровки сообщений, зашифрованных открытым ключом
используется открытый ключ:
- для проверки подписей сообщений, подписанных закрытым ключом
- для шифрования сообщений