IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Services Web Discussion :

Accès à un WS sécurisé - version http non supportée + "No Security Header in message"


Sujet :

Services Web

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    6
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 6
    Points : 4
    Points
    4
    Par défaut Accès à un WS sécurisé - version http non supportée + "No Security Header in message"
    Bonjour à tous,

    Je bloque sur ce problème depuis 2 jours, et malheureusement je n'arrive pas à isoler l'origine de celui-ci.

    Je dois développer créer et déployer des web services sécurisés en JEE via Netbeans 6.0, Metro WSIT, et le serveur d'applications apache tomcat 5.5.
    Ceux-ci doivent être accessibles et facilement utilisables depuis un projet Visual Studio 2005.
    Je pense avoir correctement réussi la config de mon serveur d'appli, (ajout des bonnes librairies, création keystore, certificat via l'outil java "keytool", etc...)
    Quand je déploie un web service classique, aucun problème, VS le reconnait et l'exploite facilement.
    Si j'ajoute de la sécuration https (SSL), encore une fois, cela réussit.

    THE problem:
    Si je modifie mon Service pour que celui-ci demande une authentification basique (nom d'utilisateur et mot de passe définis dans un fichier de config d'Apache Tomcat), je parviens à ajouter la Web Référence à mon projet VS, mais voici ce que j'obtiens à l'exécution:

    L'exception System.Net.WebException n'a pas été gérée

    Message="La demande a échoué avec l'état HTTP 505 : Version HTTP Non Supportée."

    Source="System.Web.Services"

    StackTrace:

    à System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

    à System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

    à WindowsApplication1.WebReference.ServicesService.operation(Int32 p1, Int32 p2, Int32 p3) dans E:\Mes documents\Visual Studio Projects\WindowsApplication1\WindowsApplication1\Web References\WebReference\Reference.cs:ligne 79

    à WindowsApplication1.Form1.button1_Click(Object sender, EventArgs e) dans E:\Mes documents\Visual Studio Projects\WindowsApplication1\WindowsApplication1\Form1.cs:ligne 41

    à System.Windows.Forms.Control.OnClick(EventArgs e)

    à System.Windows.Forms.Button.OnClick(EventArgs e)

    à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

    à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

    à System.Windows.Forms.Control.WndProc(Message& m)

    à System.Windows.Forms.ButtonBase.WndProc(Message& m)

    à System.Windows.Forms.Button.WndProc(Message& m)

    à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

    à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

    à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

    à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

    à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

    à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

    à System.Windows.Forms.Application.Run(Form mainForm)

    à WindowsApplication1.Program.Main() dans E:\Mes documents\Visual Studio Projects\WindowsApplication1\WindowsApplication1\Program.cs:ligne 17

    à System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

    à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

    à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

    à System.Threading.ThreadHelper.ThreadStart_Context(Object state)

    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

    à System.Threading.ThreadHelper.ThreadStart()

    Je fournis également le code qui fait appel à ce Web Service:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
     
    using System;
     
    using System.Collections.Generic;
     
    using System.ComponentModel;
     
    using System.Data;
     
    using System.Drawing;
     
    using System.Text;
     
    using System.Windows.Forms;
     
    using WindowsApplication1.WebReference;
     
    using System.Web.Services;
     
    using System.Web.Services.Protocols;
     
    using System.Security.Cryptography.X509Certificates;
     
    using System.Net;
     
    using System.Net.Security;
     
     
     
     
     
    namespace WindowsApplication1
     
    {
     
        public partial class Form1 : Form
     
        {
     
            public Form1()
     
            {
     
                InitializeComponent();
     
            }
     
     
     
            private void button1_Click(object sender, EventArgs e)
     
            {
     
     
     
                    // On indique la validation automatique des
     
                    // demandes d'acceptation des certificats
     
                    System.Net.ServicePointManager.ServerCertificateValidationCallback = TrustAllCertificateCallback;
     
     
     
     
     
                    // Instanciation de la classe proxy permettant
     
                    // l'appel distant au Webservice            
     
                    ServicesService vWSClient = new ServicesService();
     
                    // vWSClient.Timeout = -1;
     
     
     
                    // Définir les données d'identification
     
                    vWSClient.Credentials = new NetworkCredential("wsuid", "wspwd");
     
     
     
                    // Appel au Web Service
                    wsLocation[] vList = vWSClient.operation(1, 2, 3);
     
     
     
                    int vNbEl = vList == null ? 0 : vList.Length;
     
                    MessageBox.Show("taille de la liste : " + vNbEl);
     
     
     
            }
     
     
     
            public static bool TrustAllCertificateCallback(object sender,
     
                X509Certificate cert, X509Chain chain, SslPolicyErrors errors)
     
            {
     
                return true;
     
            }
     
     
     
     
     
        }
     
    }
    Si vous avez une idée, je suis preneur. Je suis complètement paralysé.

    Dans cette situation, le problème ne vient peut etre pas de Visual Studio, là est toute la difficulté, si vous pouviez tout de même me communiquer votre avis

    Merci beaucoup.

  2. #2
    Candidat au Club
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    6
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 6
    Points : 4
    Points
    4
    Par défaut Solution trouvée, mais nouvelle quête... :)
    J'ai résolu le problème de l'erreur 505. C'était apparemment du à tomcat. Problème de reconnaissance entre http 1.0 et 1.1.
    Pour que http 1.1 soit correctement supporté il m'a fallu ajouter ce code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    [...]
    System.Net.ServicePointManager.ServerCertificateValidationCallback = TrustAllCertificateCallback;
    
    ServicePointManager.Expect100continue = false;
    
    // Instanciation de la classe proxy permettant
    // l'appel distant au Webservice            
    ServicesService vWSClient = new ServicesService();
    [...]
    Pour le nouveau problème, cette fois-ci les modifications sont peut-être à mener du coté serveur, je vous l'expose tout de même.
    Le web service est accessible et fonctionnel lorsque je ne passe pas par l'assistant netbeans pour configurer la sécurisation (c'est à dire en bidouillant juste mon web.xml).
    Si j'essaie de suivre la démarche officielle de l'assistant (choix du mode de sécurisation, choix de l'algorithme de cryptage, etc...) l'on m'adresse un warning:
    "Avertissement de l'outil personnalisé: Au moins une importation ServiceDescriptionFormatExtension facultative a été ignorée"
    A l'exécution, j'obtiens une exception
    System.Web.Services.Protocols.SoapException, "Security Requirements not met - No Security header in message".
    L'exception System.Web.Services.Protocols.SoapException n'a pas été gérée

    Message="Security Requirements not met - No Security header in message"

    Source="System.Web.Services"

    Actor=""

    Lang=""

    Node=""

    Role=""

    StackTrace:

    à System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

    à System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

    à WindowsApplication1.WebReference.ServicesService.operation(Int32 p1, Int32 p2, Int32 p3) dans E:\Mes documents\Visual Studio Projects\WindowsApplication1\WindowsApplication1\Web References\WebReference\Reference.cs:ligne 80

    à WindowsApplication1.Form1.button1_Click(Object sender, EventArgs e) dans E:\Mes documents\Visual Studio Projects\WindowsApplication1\WindowsApplication1\Form1.cs:ligne 41

    à System.Windows.Forms.Control.OnClick(EventArgs e)

    à System.Windows.Forms.Button.OnClick(EventArgs e)

    à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

    à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

    à System.Windows.Forms.Control.WndProc(Message& m)

    à System.Windows.Forms.ButtonBase.WndProc(Message& m)

    à System.Windows.Forms.Button.WndProc(Message& m)

    à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

    à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

    à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

    à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

    à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

    à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

    à System.Windows.Forms.Application.Run(Form mainForm)

    à WindowsApplication1.Program.Main() dans E:\Mes documents\Visual Studio Projects\WindowsApplication1\WindowsApplication1\Program.cs:ligne 17

    à System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)

    à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

    à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

    à System.Threading.ThreadHelper.ThreadStart_Context(Object state)

    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

    à System.Threading.ThreadHelper.ThreadStart()
    Coté développement du web service sous netbeans, lorsque je suis la démarche rigoureuse de sécurisation, le fichier wsit-webservices.Services.xml change considérablement:

    wsit-webservices.Services.xml en contournant l'assistant visuel de netbeans (pas de détail pour l'encryptage des données, etc.):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
     
    <?xml version="1.0" encoding="UTF-8"?> 
     <definitions 
     xmlns="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="ServicesService" targetNamespace="http://webservices/" xmlns:tns="http://webservices/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsaws="http://www.w3.org/2005/08/addressing" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" xmlns:sc="http://schemas.sun.com/2006/03/wss/server" xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy" 
     >
        <message name="operation"/>
        <message name="operationResponse"/>
        <portType name="Services">
            <operation name="operation">
                <input message="tns:operation"/>
                <output message="tns:operationResponse"/>
            </operation>
        </portType>
        <binding name="ServicesPortBinding" type="tns:Services">
            <operation name="operation">
                <input></input>
                <output></output>
            </operation>
        </binding>
        <service name="ServicesService">
            <port name="ServicesPort" binding="tns:ServicesPortBinding"/>
        </service>
    </definitions>
    wsit-webservices.Services.xml en passant par l'assistant design Services de Netbeans:

    - Message authentication over SSL
    - Authentication token: Username
    - WSS Version: 1.0
    - Algorithm Suite: Basic 128 bits
    - Security Header layout: Lax
    - Establish secure session: non cochée
    - Encrypt signature: non cochée

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
     
    <?xml version="1.0" encoding="UTF-8"?> 
     <definitions 
     xmlns="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
     xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="ServicesService" targetNamespace="http://webservices/" xmlns:tns="http://webservices/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsaws="http://www.w3.org/2005/08/addressing" xmlns:sc="http://schemas.sun.com/2006/03/wss/server" xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy" xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy" 
     >
        <message name="operation"/>
        <message name="operationResponse"/>
        <portType name="Services">
            <operation name="operation">
                <input message="tns:operation"/>
                <output message="tns:operationResponse"/>
            </operation>
        </portType>
        <binding name="ServicesPortBinding" type="tns:Services">
            <wsp:PolicyReference URI="#ServicesPortBindingPolicy"/>
            <operation name="operation">
                <input></input>
                <output></output>
            </operation>
        </binding>
        <service name="ServicesService">
            <port name="ServicesPort" binding="tns:ServicesPortBinding"/>
        </service>
        <wsp:Policy wsu:Id="ServicesPortBindingPolicy">
            <wsp:ExactlyOne>
                <wsp:All>
                    <wsaws:UsingAddressing xmlns:wsaws="http://www.w3.org/2006/05/addressing/wsdl"/>
                    <sp:TransportBinding>
                        <wsp:Policy>
                            <sp:TransportToken>
                                <wsp:Policy>
                                    <sp:HttpsToken RequireClientCertificate="false"/>
                                </wsp:Policy>
                            </sp:TransportToken>
                            <sp:Layout>
                                <wsp:Policy>
                                    <sp:Lax/>
                                </wsp:Policy>
                            </sp:Layout>
                            <sp:IncludeTimestamp/>
                            <sp:AlgorithmSuite>
                                <wsp:Policy>
                                    <sp:Basic128/>
                                </wsp:Policy>
                            </sp:AlgorithmSuite>
                        </wsp:Policy>
                    </sp:TransportBinding>
                    <sp:Wss10>
                        <wsp:Policy>
                            <sp:MustSupportRefKeyIdentifier/>
                        </wsp:Policy>
                    </sp:Wss10>
                    <sp:SignedSupportingTokens>
                        <wsp:Policy>
                            <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
                                <wsp:Policy>
                                    <sp:WssUsernameToken10/>
                                </wsp:Policy>
                            </sp:UsernameToken>
                        </wsp:Policy>
                    </sp:SignedSupportingTokens>
                </wsp:All>
            </wsp:ExactlyOne>
        </wsp:Policy>
    </definitions>
    Voila, c'est à peu près tout, je suis entrain de vérifier ma configuration coté serveur d'applications, support web services, etc... Je vous tiens au courant.

    Merci

  3. #3
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : France, Nord (Nord Pas de Calais)

    Informations forums :
    Inscription : Mars 2008
    Messages : 1
    Points : 1
    Points
    1
    Par défaut
    Merci pour cette réponse qui fonctionne.
    L'instruction exacte a ajoutée est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    System.Net.ServicePointManager.Expect100Continue = false;

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Mozilla déclare la guerre contre le HTTP non-sécurisé
    Par Amine Horseman dans le forum Sécurité
    Réponses: 81
    Dernier message: 17/06/2015, 15h51
  2. Réponses: 0
    Dernier message: 28/01/2015, 10h00
  3. Réponses: 0
    Dernier message: 18/09/2013, 10h43
  4. [Accents - XML] Problème de codage non supporté !!
    Par Smortex dans le forum Composants VCL
    Réponses: 6
    Dernier message: 24/11/2002, 11h00
  5. [CR8][Delphi6] erreur imprimante non supportée
    Par Sebastien L. dans le forum SDK
    Réponses: 3
    Dernier message: 12/09/2002, 15h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo