Bonjour à tous,
Je ne parviens pas à résoudre ce problème
Je dois sécuriser des Web Services sous netbeans avec apache tomcat 5.5 pour serveur d'applications.
J'ai installé Metro, WSIT, JAX-WS.. (Cf: https://metro.dev.java.net/1.1/ )
Et je souhaite utiliser des WebServices sécurisé par authentification basique et par SSL.
J'ai généré le certificat via l'outil keytool, comme décrit dans les différents tuto.
Au déploiement, coté serveur, je ne remarque aucun problème (acceptation du certif, authentification...)
Si je me contente d'une connexion sécurisée en https, pas de problème. Mais dès que j'ajoute une authentification, le client ne veut rien entendre (Visual Studio, ou même Netbeans).
Ce qui est très difficile pour moi, c'est de ne pas pouvoir trouver l'origine du problème: config de tomcat, installation de metro, déploiement d'un WS netbeans, utilisation d'un WS depuis visual studio...? Ce n'est pas vraiment évident : /
Authentification BASIC via MemoryRealm (tomcat-users)
Si je ne passe pas par SSL :
Au niveau de l'appel au webservice: déclenchement de "WebException" avec pour propriété status "ProtocolError", code 505 "http version not supported"
Coté Visual Studio, cela donne donc:
Sans SSL
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 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 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()
Avec SSL:
Je n'arrive pas non plus a jouter ce web service client dans un projet Netbeans:
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 L'exception System.Net.WebException n'a pas été gérée Message="La connexion sous-jacente a été fermée : Impossible d'établir une relation de confiance pour le canal sécurisé SSL/TLS." Source="System.Web.Services" StackTrace: à System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) à System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) à System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) à ClientConsole.WebReference.ServicesService.operation(Int32 p1, Int32 p2, Int32 p3) dans E:\Mes documents\Visual Studio 2005\Projects\ClientConsole\ClientConsole\Web References\WebReference\Reference.cs:ligne 80 à ClientConsole.Program.Main(String[] args) dans E:\Mes documents\Visual Studio 2005\Projects\ClientConsole\ClientConsole\Program.cs:ligne 21 à 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()
fenêtre Pop-up:
"Problem with downloading wsdl or schema file. Check the URL, proxy settings or whether the server is running."
Si cela peut aider, voici le web.xml de mon appli et une partie du server.xml
web.xml
server.xml
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 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <listener> <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class> </listener> <servlet> <servlet-name>Services</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Services</servlet-name> <url-pattern>/Services</url-pattern> </servlet-mapping> <session-config> <session-timeout> 30 </session-timeout> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <security-constraint> <display-name>SSL transport for ServicesService </display-name> <web-resource-collection> <web-resource-name>Secure Area</web-resource-name> <description/> <url-pattern>/Services/*</url-pattern> <url-pattern>/*</url-pattern> <url-pattern>/ServicesService/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> <http-method>HEAD</http-method> <http-method>PUT</http-method> <http-method>OPTIONS</http-method> <http-method>TRACE</http-method> <http-method>DELETE</http-method> </web-resource-collection> <auth-constraint> <role-name>wsclient</role-name> </auth-constraint> <user-data-constraint> <description/> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>BASIC</auth-method> <realm-name>MemoryRealm</realm-name> </login-config> <security-role> <description/> <role-name>wsclient</role-name> </security-role> </web-app>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 [...] <Connector port="8443" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="true" disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" SSLEnabled="true" keystoreFile=chemin/vers/apache-tomcat-5.5/keystore" keystorePass="password" clientAuth="false" sslProtocol="TLS"/> [...] <Realm className="org.apache.catalina.realm.MemoryRealm" /> [...]
Toute aide est la bienvenue.
Merci.
Saitou-San
Partager