You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to mock the responses of some APIs that produces our web app from the Firefox Browser.
The web app works using https protocol.
So what I want is that Wiremock intercept some APIs from the browser and mock some of its responses.
My knowledge on SSL certificates is limited.
I have executed
dotnet dev-certs https --trust
as suggest WireMock and below is my code. I have also created my own CA approved certificate and added options into Selenium to ignore SSL errors but nothing.
Wiremock works fine if I call to the wiremock URL mocked api it returns the expected mocked value but I cannot navigate to nay website like google one so this line fails:
driver.Navigate().GoToUrl("https://www.google.com"); // here will be my web app URL but it fails
The failure that I get is:
Secure Connection Failed
The page you are tryining to view cannot be shown because the authenticity of the received data could not be verified.
Could you please help me on this matter?
I tried also into the certificate use the generated by WireMock (My = CurrentUser - localhost) but nothing.
Thank you very much
usingSystem;usingOpenQA.Selenium;usingOpenQA.Selenium.Firefox;usingOpenQA.Selenium.Remote;usingWireMock.Logging;usingWireMock.Server;usingWireMock.Settings;classProgram{staticvoidMain(string[]args){varserver=WireMockServer.Start(newWireMockServerSettings{UseSSL=true,Port=8443,CertificateSettings=newWireMockCertificateSettings(){X509CertificateFilePath="./WireMockCertificate/server.pfx",X509CertificatePassword="password123"},Logger=newWireMockConsoleLogger()});Console.WriteLine($"WireMock Server is running at: {server.Urls[0]}");server.Given(WireMock.RequestBuilders.Request.Create().WithPath("/api/test").UsingGet()).RespondWith(WireMock.ResponseBuilders.Response.Create().WithStatusCode(200).WithBody("Hello from WireMock via Proxy!"));try{varproxy=newProxy{SslProxy="localhost:8443",};varoptions=newFirefoxOptions{AcceptInsecureCertificates=true};options.SetPreference("security.enterprise_roots.enabled",true);options.SetPreference("network.proxy.type",1);options.SetPreference("network.proxy.ssl","localhost");options.SetPreference("network.proxy.ssl_port",8443);options.AddArgument("--ignore-ssl-errors=yes");options.AddArgument("--allow-insecure-localhost");using(IWebDriverdriver=newFirefoxDriver(options)){driver.Navigate().GoToUrl("https://www.google.com");// here will be my web app URL but it fails driver.Navigate().GoToUrl("https://localhost:8443/api/test");Console.WriteLine("Response from WireMock:");Console.WriteLine(driver.PageSource);}}catch(Exceptionex){Console.WriteLine("An error occurred:");Console.WriteLine(ex.Message);}finally{// Stop and dispose the WireMock serverserver.Stop();server.Dispose();}}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I want to mock the responses of some APIs that produces our web app from the Firefox Browser.
The web app works using https protocol.
So what I want is that Wiremock intercept some APIs from the browser and mock some of its responses.
My knowledge on SSL certificates is limited.
I have executed
dotnet dev-certs https --trust
as suggest WireMock and below is my code. I have also created my own CA approved certificate and added options into Selenium to ignore SSL errors but nothing.
Wiremock works fine if I call to the wiremock URL mocked api it returns the expected mocked value but I cannot navigate to nay website like google one so this line fails:
The failure that I get is:
Secure Connection Failed
The page you are tryining to view cannot be shown because the authenticity of the received data could not be verified.
Could you please help me on this matter?
I tried also into the certificate use the generated by WireMock (My = CurrentUser - localhost) but nothing.
Thank you very much
Beta Was this translation helpful? Give feedback.
All reactions