簡體   English   中英

為 Axis2 web 服務創建客戶端時對傳輸和消息使用不同的證書

[英]Using different certificate for both transport and message when creating client for Axis2 web service

我正在嘗試為axis2 web 服務編寫客戶端,該服務需要使用一個證書簽署消息並使用不同的證書進行傳輸。

我有 WSDL 但是在使用 SvcUtil 導入服務后我有一個問題要使用什么綁定,並且 ClientCredentials.ClientCertificate.Certificate 似乎只允許一個證書,如果我設置綁定 Security.Mode.TransportWithMessageCredential 並將兩種憑據類型設置為對於傳輸和消息,我在跟蹤中沒有獲得 TLS 證書。

使用所有 XSD 鏈接到 WSDL,包括 oasis-200401-wss-security-utility-1.0.xsd

https://drive.google.com/file/d/1liiTyw4jWdiraR0JnZ3MM1doYDq9Bq1S/view?usp=sharing

如果我只做傳輸,那么 tls 可以工作,但我得到 wsse:security header 從服務器丟失。

        System.Net.ServicePointManager.SecurityProtocol=System.Net.SecurityProtocolType.Tls12;
        
        System.ServiceModel.WSHttpBinding bindingws=new System.ServiceModel.WSHttpBinding();
        bindingws.Security=new System.ServiceModel.WSHttpSecurity();
        bindingws.Security.Mode=System.ServiceModel.SecurityMode.Transport;
        //bindingws.Security.Mode=System.ServiceModel.SecurityMode.TransportWithMessageCredential;
        bindingws.Security.Transport.ClientCredentialType=System.ServiceModel.HttpClientCredentialType.Certificate;
        //bindingws.Security.Message.ClientCredentialType=System.ServiceModel.MessageCredentialType.Certificate;
        
        eskierowanie.ObslugaSkierowaniaWSClient os=new XRis.eskierowanie.ObslugaSkierowaniaWSClient(bindingws,new System.ServiceModel.EndpointAddress("https://isus.ezdrowie.gov.pl/services/ObslugaSkierowaniaWS"));
        System.Security.Cryptography.X509Certificates.X509Certificate2 tls_cert=new System.Security.Cryptography.X509Certificates.X509Certificate2(@"certificate-tls.p12","Password", System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable |  System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.PersistKeySet |  System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.UserKeySet);
        System.Security.Cryptography.X509Certificates.X509Certificate2 wss_cert=new System.Security.Cryptography.X509Certificates.X509Certificate2(@"certificate-wss.p12","Password", System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.Exportable |  System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.PersistKeySet |  System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.UserKeySet);
        os.ClientCredentials.ClientCertificate.Certificate=tls_cert;
        
        //filling the request
        eskierowanie.KontekstMT kontekst=new XRis.eskierowanie.KontekstMT();
        eskierowanie.WyszukanieSkierowanUslugobiorcyRequest wsur=new XRis.eskierowanie.WyszukanieSkierowanUslugobiorcyRequest();
        eskierowanie.KryteriaWyszukiwaniaSkierowanUslugobiorcyMT kryt=new XRis.eskierowanie.KryteriaWyszukiwaniaSkierowanUslugobiorcyMT();
        eskierowanie.IdentyfikatorUslugobiorcyOIDMT id_uslugobiorcy=new XRis.eskierowanie.IdentyfikatorUslugobiorcyOIDMT();
        id_uslugobiorcy.extension="111111111";
        id_uslugobiorcy.root="2.11.1111.1.111111.1.11111.1.1.111";
        kryt.idUslugobiorcy=id_uslugobiorcy;
        wsur.kryteriaWyszukiwaniaSkierowanUslugobiorcy=kryt;
        

        eskierowanie.WyszukanieSkierowanUslugobiorcyResponse response=os.wyszukanieSkierowanUslugobiorcy(kontekst,wsur);
        System.Windows.Forms.MessageBox.Show(response.wynik.komunikat);

在 SoapUI 測試套件中,它顯示它應該如下所示:

    POST https://isus.ezdrowie.gov.pl/services/ObslugaSkierowaniaWS HTTP/1.1
    Accept-Encoding: gzip,deflate
    Content-Type: text/xml;charset=UTF-8
    SOAPAction: "urn:wyszukanieSkierowanUslugobiorcy"
    Content-Length: 5913
    Host: isus.ezdrowie.gov.pl
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
    
    <soapenv:Envelope xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v20="http://csioz.gov.pl/p1/kontekst/mt/v20180509" xmlns:v201="http://csioz.gov.pl/p1/eskierowanie/ws/v20180509" xmlns:v202="http://csioz.gov.pl/p1/eskierowanie/mt/v20180509" xmlns:v203="http://csioz.gov.pl/p1/wspolne/mt/v20180509">
       <soapenv:Header><wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><xenc:EncryptedKey Id="EK-4774053CD62669762616081091569011" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"/><ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><wsse:SecurityTokenReference><ds:X509Data><ds:X509IssuerSerial><ds:X509IssuerName>C=PL,O=CSIOZ,OU=P1 Integracyjne,CN=CC P1 SubCA WSS</ds:X509IssuerName><ds:X509SerialNumber>45462786551181900</ds:X509SerialNumber></ds:X509IssuerSerial></ds:X509Data></wsse:SecurityTokenReference></ds:KeyInfo><xenc:CipherData><xenc:CipherValue>CJRtZ7asgtnYVPYJPkmV93e6+ehpZDyv4RxnXg6lcHPrl5RBZhHPt3tdigdCHlOUO0lhh4daujiyulEnPkhHvjodNRDdjfHccKfHM6oojCDpB6mxVuZOKpuW2els8DwxGAu0XUM6pGL6HMndgSzeusK2DMZiBNRN4BfDSBYsWPU7TtpveywRvo090PNTpFuJV/E3g0JP5s2jHEFrHusDqjXPb4aJ/2Y2KEI8Q7b79Of0i5GApMxWF4ZBKmJ+rNHiNHH8nvcapLm0mNxkx6TIu0JXUVPmlKmcMR4YzXMb1M0VAPQ12o6sYEw3sDNUGv+NYpx2evF9fz4cIC/BfzhFnA==</xenc:CipherValue></xenc:CipherData><xenc:ReferenceList><xenc:DataReference URI="#ED-4774053CD62669762616081091569192"/></xenc:ReferenceList></xenc:EncryptedKey></wsse:Security>
          <v20:kontekstWywolania>
             <v20:atrybut nazwa="urn:csioz:p1:kontekst:idPodmiotuOidRoot">
                    <v20:wartosc>2.16.840.1.11111.3.4424.2.3.1</v20:wartosc>
                </v20:atrybut>
          </v20:kontekstWywolania>
       </soapenv:Header>
       <soapenv:Body><xenc:EncryptedData Id="ED-4774053CD62669762616081091569192" Type="http://www.w3.org/2001/04/xmlenc#Content" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/><ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><wsse:SecurityTokenReference wsse11:TokenType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd"><wsse:Reference URI="#EK-4774053CD62669762616081091569011"/></wsse:SecurityTokenReference></ds:KeyInfo><xenc:CipherData><xenc:CipherValue>eC2ISsPnEZz3jr24keZDQH5emcCm07byUxffjCozzbRhXKUCu5epfje7auN5OPmx0WHnfS72GUEFa0aQsHVtr0tiqXxSv9r08jPZblN0okKYIypQALY+V5YE4WfSuwfj9M848mf225+UGEQtHbNjD7fDn4E2L1sOrYqwxEsC5BRA/nxCTR+kkNFnRFRKoVbJ19URMcIS2Tj5E+U0RGAnXeWQJ+nltjOVgS1lG7+FKkH/Qvr/KpovwV9ODisflZkRdO13VoqdMlnybpkQSH63aLhLiu7ybBHwqVew5nFsISCeoeIyEx/t5r7inZ4QFPPo/VTpt7tdbaOewAT1xYVA27iotY/8lCQ4SN4LKBZvVYDCrCD9oD3Rl3T/NqeS2tzEk+liowE/YjJgOB3wcZ4T0y6Z6SSAtX+dD8UyiGU5eqKzd3cQyaR711fKyceM3ufnE6RtJmdzVBeFCIHsDcARzUccOnGuokyGPhBliyAInmmyDksRuWXe44doBS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3FdPyB4s8DSULC5XzghcnxsGAgxBpFH6qAj1q2IACRbyg8TiHOC1qdYpNC10gLsRoX+w8itJtsSdKPkwwiQ7UzIbnHRbxy5Svk9qBKAytftX1dT+NC+T6O3Tv8RFB8M4ctsJ1fbMUOHcjX7rHBxi5FTeSEEPea4Zk/iT/nv7zkNtthrIivVWtz1FUFaXYMhIWNEdGUEwrr0gKbClr5alDsHJW9DeoIgYNWOQBvJB2hLUfi4t6VYb2IC0hsc4poB3x4+Urnwp9ieorWIAZ0cRo+NWFE2y6Bry7jtRRfaA0T0PmUvuEhWS+eWKDEcqTFReDPKQxU3fI99MxmYubvfIIc2uiNmBagPn8yCYWnPVDmHOT+brLbs6/Wf0RAR8xYR9nAAOs+rcVtry9vxciH7+PU1AyzlpRWERUF2NqXqT8kHe2z8U2WxJ66pzlwrPRNg6FlXmwkW+BTQFXNr74zDO1mzvPdIdwbHZDz6vVN0mIMEkCvytqNVMAT+efCk4ka9AG/CClJI3aBZcYgF0W2QBGDlgypPAnAHQMTeT1dEmHPcbnoSo1678nycvrnLQlCkWQE7uArhPX0GBKhN8SHoehBhHrnTPgpg8pV0m1mqqwHc32PWmmZQOBOPNJM7DzfIWOxIoGrRDpK2Wc3TCPGQu6RXoGVjyGtqvtE4nA+8g4DcUi/hrsnLrMxIiSfRTuRqyl1qaX5Qq22EjZIjAHk5+vFzdfpeXWKcXj12qHE7lIcx0J6f+UZ7UDLc=</xenc:CipherValue></xenc:CipherData></xenc:EncryptedData></soapenv:Body>
    </soapenv:Envelope>

任何關於如何 go 在 C# 中的提示將不勝感激。

順便說一句,有沒有辦法在使用 svcutil 時使用 tls 證書身份驗證,因為現在我只是通過瀏覽器下載所有文件,然后導入本地文件。

嘗試以下操作:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Xml;
using System.Xml.Linq;
using System.IO;
namespace ConsoleApplication179
{
    class Program
    {
        const string  URL = "//isus.ezdrowie.gov.pl/services/ObslugaSkierowaniaWS HTTP/1.1";
        static void Main(string[] args)
        {
            string xml = 
                 "<soapenv:Envelope" +
                    " xmlns:oas=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\"" +
                    " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
                    " xmlns:v20=\"http://csioz.gov.pl/p1/kontekst/mt/v20180509\"" +
                    " xmlns:v201=\"http://csioz.gov.pl/p1/eskierowanie/ws/v20180509\"" +
                    " xmlns:v202=\"http://csioz.gov.pl/p1/eskierowanie/mt/v20180509\"" +
                    " xmlns:v203=\"http://csioz.gov.pl/p1/wspolne/mt/v20180509\">"+
       
                      "<soapenv:Header>" +
                         "<wsse:Security soapenv:mustUnderstand=\"1\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">" +
                             "<xenc:EncryptedKey Id=\"EK-4774053CD62669762616081091569011\" xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\">" +
                                "<xenc:EncryptionMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p\"/>"+
                                "<ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">" +
                                   "<wsse:SecurityTokenReference><ds:X509Data><ds:X509IssuerSerial>" +
                                   "<ds:X509IssuerName>C=PL,O=CSIOZ,OU=P1 Integracyjne,CN=CC P1 SubCA WSS</ds:X509IssuerName>" +
                                   "<ds:X509SerialNumber></ds:X509SerialNumber>" +
                                   "</ds:X509IssuerSerial>" +
                                   "</ds:X509Data></wsse:SecurityTokenReference>" +
                                "</ds:KeyInfo>"+
                                "<xenc:CipherData>" +
                                   "<xenc:CipherValue></xenc:CipherValue>" +
                                "</xenc:CipherData>" +
                                "<xenc:ReferenceList>" +
                                   "<xenc:DataReference URI=\"#ED-4774053CD62669762616081091569192\"/>" +
                                "</xenc:ReferenceList>" +
                             "</xenc:EncryptedKey>" +
                         "</wsse:Security>" +
                         "<v20:kontekstWywolania>" +
                            "<v20:atrybut nazwa=\"urn:csioz:p1:kontekst:idPodmiotuOidRoot\">" +
                               "<v20:wartosc>2.16.840.1.11111.3.4424.2.3.1</v20:wartosc>" +
                            "</v20:atrybut>" +
                         "</v20:kontekstWywolania>" +
                      "</soapenv:Header>" +
                      "<soapenv:Body>" +
                         "<xenc:EncryptedData Id=\"ED-4774053CD62669762616081091569192\" Type=\"http://www.w3.org/2001/04/xmlenc#Content\" xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\">" +
                            "<xenc:EncryptionMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#aes128-cbc\"/>" +
                            "<ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">" +
                                "<wsse:SecurityTokenReference wsse11:TokenType=\"http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#EncryptedKey\" xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\" xmlns:wsse11=\"http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd\">" +
                                   "<wsse:Reference URI=\"#EK-4774053CD62669762616081091569011\"/>" +
                                "</wsse:SecurityTokenReference>" +
                            "</ds:KeyInfo>" +
                            "<xenc:CipherData>" +
                               "<xenc:CipherValue>eC2ISsPnEZz3jr24keZDQH5emcCm07byUxffjCozzbRhXKUCu5epfje7auN5OPmx0WHnfS72GUEFa0aQsHVtr0tiqXxSv9r08jPZblN0okKYIypQALY+V5YE4WfSuwfj9M848mf225+UGEQtHbNjD7fDn4E2L1sOrYqwxEsC5BRA/nxCTR+kkNFnRFRKoVbJ19URMcIS2Tj5E+U0RGAnXeWQJ+nltjOVgS1lG7+FKkH/Qvr/KpovwV9ODisflZkRdO13VoqdMlnybpkQSH63aLhLiu7ybBHwqVew5nFsISCeoeIyEx/t5r7inZ4QFPPo/VTpt7tdbaOewAT1xYVA27iotY/8lCQ4SN4LKBZvVYDCr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LEgJkHaP6lmnnrQRditIGsrksg0IUDpOoIG0jlNXN2Vfo8ZQQLWCBf/L2ol4299T81CjysH9ZjR3au03nxC5VTxjODEhK4F/19uIjyOnyBrDoXvDf5qWjNl9zSQZJlViRYzBxy8likhwnc3FdPyB4s8DSULC5XzghcnxsGAgxBpFH6qAj1q2IACRbyg8TiHOC1qdYpNC10gLsRoX+w8itJtsSdKPkwwiQ7UzIbnHRbxy5Svk9qBKAytftX1dT+NC+T6O3Tv8RFB8M4ctsJ1fbMUOHcjX7rHBxi5FTeSEEPea4Zk/iT/nv7zkNtthrIivVWtz1FUFaXYMhIWNEdGUEwrr0gKbClr5alDsHJW9DeoIgYNWOQBvJB2hLUfi4t6VYb2IC0hsc4poB3x4+Urnwp9ieorWIAZ0cRo+NWFE2y6Bry7jtRRfaA0T0PmUvuEhWS+eWKDEcqTFReDPKQxU3fI99MxmYubvfIIc2uiNmBagPn8yCYWnPVDmHOT+brLbs6/Wf0RAR8xYR9nAAOs+rcVtry9vxciH7+PU1AyzlpRWERUF2NqXqT8kHe2z8U2WxJ66pzlwrPRNg6FlXmwkW+BTQFXNr74zDO1mzvPdIdwbHZDz6vVN0mIMEkCvytqNVMAT+efCk4ka9AG/CClJI3aBZcYgF0W2QBGDlgypPAnAHQMTeT1dEmHPcbnoSo1678nycvrnLQlCkWQE7uArhPX0GBKhN8SHoehBhHrnTPgpg8pV0m1mqqwHc32PWmmZQOBOPNJM7DzfIWOxIoGrRDpK2Wc3TCPGQu6RXoGVjyGtqvtE4nA+8g4DcUi/hrsnLrMxIiSfRTuRqyl1qaX5Qq22EjZIjAHk5+vFzdfpeXWKcXj12qHE7lIcx0J6f+UZ7UDLc=</xenc:CipherValue>" +
                            "</xenc:CipherData>" +
                         "</xenc:EncryptedData>" +
                      "</soapenv:Body>" +
                 "</soapenv:Envelope>";

            XDocument doc = XDocument.Parse(xml);

            string serialNumber = "45462786551181900</";
            string cipherValue = "CJRtZ7asgtnYVPYJPkmV93e6+ehpZDyv4RxnXg6lcHPrl5RBZhHPt3tdigdCHlOUO0lhh4daujiyulEnPkhHvjodNRDdjfHccKfHM6oojCDpB6mxVuZOKpuW2els8DwxGAu0XUM6pGL6HMndgSzeusK2DMZiBNRN4BfDSBYsWPU7TtpveywRvo090PNTpFuJV/E3g0JP5s2jHEFrHusDqjXPb4aJ/2Y2KEI8Q7b79Of0i5GApMxWF4ZBKmJ+rNHiNHH8nvcapLm0mNxkx6TIu0JXUVPmlKmcMR4YzXMb1M0VAPQ12o6sYEw3sDNUGv+NYpx2evF9fz4cIC/BfzhFnA==";
            
            XElement X509SerialNumber = doc.Descendants().Where(x => x.Name.LocalName == "X509SerialNumber").FirstOrDefault();
            X509SerialNumber.SetValue(serialNumber);

            XElement CipherValue = doc.Descendants().Where(x => x.Name.LocalName == "CipherValue").FirstOrDefault();
            CipherValue.SetValue(cipherValue);

            string xmlText = doc.ToString();
            byte[] byteArray = Encoding.UTF8.GetBytes(xmlText);

            WebRequest request = (WebRequest)HttpWebRequest.Create(URL);
            request.Headers.Add("Accept-Encoding", "gzip,deflate");
            request.Headers.Add("SOAPAction" , "urn:wyszukanieSkierowanUslugobiorcy");
            request.Headers.Add("HOST", "isus.ezdrowie.gov.pl");
            request.Headers.Add("Connection" , "Keep-Alive");
            request.Headers.Add("UserAgent" , "Apache-HttpClient/4.1.1 (java 1.5)");
            request.Method = "POST";

            request.ContentLength = byteArray.Length;
            Stream stream = request.GetRequestStream();
            stream.Write(byteArray, 0, byteArray.Length);
            stream.Close();

            WebResponse response = request.GetResponse();


        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM