[Webtest] Noob help with https/SSL - yes I did read previous related posts from 2005/2006

Troy McGuire webtest@lists.canoo.com
Wed, 12 Apr 2006 16:31:42 -0700


Hello, I just downloaded WebTest a couple of days ago, and joined the 
list today after searching for a solution to an error I am receiving.  I 
read the mailing list archives for 2006 and 2005, looking at any 
Subjects with "https", "SSL" (and even the ones like "Newbie Help" and 
"WebTest Problem").  After that I searched the web, but still to no 
avail as the only solution was to make use of keytool, which I have 
already done.

I have close to no experience with Java, and absolutely none with Ant.  
I'm using Fedora Core 5, and installed JDK 5 (1.5?) today.  Ant is 
version 1.6.5.  I followed the instructions for using keytool (getting 
the certificate using IE, etc), and adding properties to my WebTest 
script (while adding the property for "passphrase", which wasn't 
documented) to make sure everything is SSL ready.

I set "saveresponse" to "true", but it appears that no 
response(timestamp).html file was created.  I did a search from root for 
response*.html and only got what came with WebTest and a couple of other 
files that are obviously not related; none of them had a timestamp.

I did see someone suggesting a setting of, "javax.net.debug=all", but 
have no idea where this setting would take place, and found too many 
files with "javax.net" to know which one it might be.

The only non-standard trick that I've made, that I'm aware of, is that I 
do not have my script under the WebTest directory tree since I like to 
have all my QA scripts together in a separate directory structure.  I 
currently have the "trust.keystore" file in the same directory as the 
script.  I'm hoping this is the issue, as moving the "trust.keystore" 
file is an easy solution!

The error I get is (full output is further down):

******************************
[invoke]  INFO (com.canoo.webtest.steps.Step) - Exception thrown from 
this class: javax.net.ssl.SSLHandshakeException
[invoke]  INFO (com.canoo.webtest.steps.Step) - Message was: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target
******************************


My script is as follows (customer name and password changed to protect 
the innocent):


******************************
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM 
"/usr/local/sbin/canoo_webtest/selftests/config/WebTest.dtd">

<project name="loginpage" basedir="." default="main">
    <property name="webtest.connectioninitializer" 
value="com.canoo.webtest.security.SunJsseBaseConnectionInitializer" />
    <property name="webtest.truststore.file" value="trust.keystore" />
    <property name="webtest.truststore.passphrase" value="XXXXXX" />
    <property name="webtest.home" 
location="/usr/local/sbin/canoo_webtest" />
    <import file="${webtest.home}/lib/taskdef.xml" />
   
    <target name="main">
        <webtest name="loginpage">
            <config
                host="secure.customerdb.com"
                port="443"
                protocol="https"
                basepath="admin"
                summary="true"
                saveresponse="true"
                resultpath="results"
                resultfile="results.xml"/>
            <steps>
                <invoke
                    description="Get Login Page"
                    url="index.php" />
                <verifyTitle
                    description="Verify Login Page Title"
                    text="Customer :: Database Administration" />
            </steps>
        </webtest>
    </target>
</project>
******************************


For those sick minded enough ;) to read the full output after running 
the script, here it is.  From what I can tell, all errors following the 
first one are direct references to it.


******************************
Will use java
Buildfile: loginpage.xml
Trying to override old definition of task sleep

main:
  [webtest]  INFO (com.canoo.webtest.ant.WebtestTask) - Canoo Webtest: 
R_1274.
   [config]  INFO (com.canoo.webtest.engine.Configuration) - Surfing 
with browser Mozilla/4.0 (compatible; MSIE 6.0b; Windows 98)
    [steps]  INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: 
steps (1/2)
   [invoke]  INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: 
invoke "Get Login Page" (1/2)
   [invoke]  INFO (com.canoo.webtest.steps.request.AbstractTargetAction) 
- -> gotoTarget by URL: index.php
   [invoke]  INFO (com.canoo.webtest.steps.request.TargetHelper) - 
getting response for url: https://secure.customerdb.com/admin/index.php
   [invoke]  INFO (com.canoo.webtest.steps.request.TargetHelper) - Using 
custom initializer: 
com.canoo.webtest.security.SunJsseBaseConnectionInitializer
   [invoke]  INFO 
(com.canoo.webtest.security.SunJsseBaseConnectionInitializer) - 
Installing HostnameVerifier
   [invoke]  INFO (com.canoo.webtest.steps.Step) - Running with: Canoo 
Webtest: R_1274.
   [invoke]  INFO (com.canoo.webtest.steps.Step) - Exception thrown from 
this class: javax.net.ssl.SSLHandshakeException
   [invoke]  INFO (com.canoo.webtest.steps.Step) - Message was: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target
   [invoke] ERROR (com.canoo.webtest.steps.Step) - Cannot handle 
unexpected exception in step InvokePage at 
/usr/local/www/customer.com/qa/canoo_webtest/loginpage.xml:25:  with 
(taskName="invoke", description="Get Login Page", url="index.php", 
method="GET")
   [invoke] javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target
   [invoke]     at 
com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1476)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:847)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:815)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1025)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:619)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
   [invoke]     at 
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
   [invoke]     at 
java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
   [invoke]     at 
org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:827)
   [invoke]     at 
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1975)
   [invoke]     at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
   [invoke]     at 
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
   [invoke]     at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
   [invoke]     at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
   [invoke]     at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
   [invoke]     at 
com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:125)
   [invoke]     at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1354)
   [invoke]     at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1321)
   [invoke]     at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:331)
   [invoke]     at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:384)
   [invoke]     at 
com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.java:69)
   [invoke]     at 
com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTargetAction.java:68)
   [invoke]     at 
com.canoo.webtest.steps.request.InvokePage.findTarget(InvokePage.java:134)
   [invoke]     at 
com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAction.java:108)
   [invoke]     at 
com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:88)
   [invoke]     at 
com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTargetAction.java:106)
   [invoke]     at 
com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTargetAction.java:78)
   [invoke]     at com.canoo.webtest.steps.Step.execute(Step.java:145)
   [invoke]     at org.apache.tools.ant.Task.perform(Task.java:364)
   [invoke]     at 
com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:59)
   [invoke]     at 
com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:39)
   [invoke]     at com.canoo.webtest.steps.Step.execute(Step.java:145)
   [invoke]     at org.apache.tools.ant.Task.perform(Task.java:364)
   [invoke]     at 
com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:126)
   [invoke]     at 
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
   [invoke]     at org.apache.tools.ant.Task.perform(Task.java:364)
   [invoke]     at org.apache.tools.ant.Target.execute(Target.java:341)
   [invoke]     at org.apache.tools.ant.Target.performTasks(Target.java:369)
   [invoke]     at 
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
   [invoke]     at 
org.apache.tools.ant.Project.executeTarget(Project.java:1185)
   [invoke]     at 
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
   [invoke]     at 
org.apache.tools.ant.Project.executeTargets(Project.java:1068)
   [invoke]     at org.apache.tools.ant.Main.runBuild(Main.java:668)
   [invoke]     at org.apache.tools.ant.Main.startAnt(Main.java:187)
   [invoke]     at 
org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
   [invoke]     at 
org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
   [invoke] Caused by: sun.security.validator.ValidatorException: PKIX 
path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target
   [invoke]     at 
sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
   [invoke]     at 
sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
   [invoke]     at 
sun.security.validator.Validator.validate(Validator.java:203)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)
   [invoke]     at 
com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:840)
   [invoke]     ... 47 more
   [invoke] Caused by: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target
   [invoke]     at 
sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:236)
   [invoke]     at 
java.security.cert.CertPathBuilder.build(CertPathBuilder.java:194)
   [invoke]     at 
sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:216)
   [invoke]     ... 52 more
   [invoke]  INFO (com.canoo.webtest.steps.Step) - Running with: Canoo 
Webtest: R_1274.
   [invoke]  INFO (com.canoo.webtest.steps.Step) - Exception thrown from 
this class: com.canoo.webtest.engine.StepExecutionException
   [invoke]  INFO (com.canoo.webtest.steps.Step) - Message was: 
Unexpected exception caught: javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target
[Fatal Error] results.xml:1:1: Content is not allowed in prolog.
ERROR (com.canoo.webtest.ant.WebtestTask) - Exception caught while 
writing test report
org.xml.sax.SAXParseException: Content is not allowed in prolog.
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:172)
        at 
com.canoo.webtest.reporting.XmlReporter.readXmlFile(XmlReporter.java:32)
        at 
com.canoo.webtest.reporting.XmlReporter.getDocument(XmlReporter.java:65)
        at 
com.canoo.webtest.reporting.XmlReporter.generateReport(XmlReporter.java:54)
        at com.canoo.webtest.ant.WebtestTask.report(WebtestTask.java:242)
        at 
com.canoo.webtest.ant.WebtestTask.callSelectedReporter(WebtestTask.java:234)
        at 
com.canoo.webtest.ant.WebtestTask.writeTestReportIfNeeded(WebtestTask.java:228)
        at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:128)
        at 
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at 
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at 
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at org.apache.tools.ant.Main.runBuild(Main.java:668)
        at org.apache.tools.ant.Main.startAnt(Main.java:187)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)

BUILD FAILED
/usr/local/www/customer.com/qa/canoo_webtest/loginpage.xml:12: Canoo 
Webtest: R_1274.
Test failed.
Exception raised: com.canoo.webtest.engine.StepExecutionException: 
Unexpected exception caught: javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target, Step: InvokePage at 
/usr/local/www/customer.com/qa/canoo_webtest/loginpage.xml:25:  with 
(taskName="invoke", description="Get Login Page", url="index.php", 
method="GET")com.canoo.webtest.engine.StepExecutionException: Unexpected 
exception caught: javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target, Step: InvokePage at 
/usr/local/www/customer.com/qa/canoo_webtest/loginpage.xml:25:  with 
(taskName="invoke", description="Get Login Page", url="index.php", 
method="GET")
        at 
com.canoo.webtest.steps.Step.handleUnexpectedException(Step.java:475)
        at 
com.canoo.webtest.steps.AbstractBrowserAction.handleUnexpectedException(AbstractBrowserAction.java:114)
        at 
com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:110)
        at 
com.canoo.webtest.steps.request.AbstractTargetAction.gotoTarget(AbstractTargetAction.java:106)
        at 
com.canoo.webtest.steps.request.AbstractTargetAction.doExecute(AbstractTargetAction.java:78)
        at com.canoo.webtest.steps.Step.execute(Step.java:145)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at 
com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:59)
        at 
com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:39)
        at com.canoo.webtest.steps.Step.execute(Step.java:145)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:126)
        at 
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at 
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at 
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at org.apache.tools.ant.Main.runBuild(Main.java:668)
        at org.apache.tools.ant.Main.startAnt(Main.java:187)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: javax.net.ssl.SSLHandshakeException: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to 
find valid certification path to requested target
        at 
com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
        at 
com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1476)
        at 
com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
        at 
com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
        at 
com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:847)
        at 
com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
        at 
com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
        at 
com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
        at 
com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:815)
        at 
com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1025)
        at 
com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:619)
        at 
com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
        at 
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
        at 
org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:827)
        at 
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1975)
        at 
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
        at 
org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
        at 
org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
        at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
        at 
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
        at 
com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:125)
        at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1354)
        at 
com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1321)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:331)
        at 
com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:384)
        at 
com.canoo.webtest.steps.request.TargetHelper.getResponse(TargetHelper.java:69)
        at 
com.canoo.webtest.steps.request.AbstractTargetAction.getResponse(AbstractTargetAction.java:68)
        at 
com.canoo.webtest.steps.request.InvokePage.findTarget(InvokePage.java:134)
        at 
com.canoo.webtest.steps.request.AbstractTargetAction$1.call(AbstractTargetAction.java:108)
        at 
com.canoo.webtest.steps.request.TargetHelper.protectedGoto(TargetHelper.java:88)
        ... 21 more
Caused by: sun.security.validator.ValidatorException: PKIX path building 
failed: sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target
        at 
sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
        at 
sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
        at sun.security.validator.Validator.validate(Validator.java:203)
        at 
com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172)
        at 
com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)
        at 
com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:840)
        ... 47 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target
        at 
sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:236)
        at 
java.security.cert.CertPathBuilder.build(CertPathBuilder.java:194)
        at 
sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:216)
        ... 52 more


Total time: 9 seconds
******************************

Thanks in advance for anyone's help!  This looks to be a promising tool 
if I can get a script to run ;)

-Troy
troy@spawnordie.com