Skip to content

Automatically select client certificate in Chrome #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cr-liorholtzman opened this issue Mar 8, 2023 · 20 comments
Closed

Automatically select client certificate in Chrome #373

cr-liorholtzman opened this issue Mar 8, 2023 · 20 comments
Milestone

Comments

@cr-liorholtzman
Copy link

The company I'm working in is currently considering using Moon to replace Zalenium since it's not possible to use client-certificate when working with Zalenium

To work with a client certificate and use chrome, it is required to import it to the pod and also set "AutoSelectCertificateForUrls".
Is it something we can do using Moon? even if it means setting some specific environment variables?

@aandryashin
Copy link
Member

aandryashin commented Mar 8, 2023 via email

@aandryashin
Copy link
Member

aandryashin commented Mar 8, 2023 via email

@slunyaak
Copy link

slunyaak commented May 2, 2024

Hi,
uploading new profile in Moon pod works. But the question is how to add into profile client certificate. I have tried following: I started Moon Chrome browser, imported in it required client certificate for mutual TLS authentication and then downloaded profile. After that I followed instruction from Moon documentation in order to upload custom Chrome profile. I did make sure, that upload of new profile was successful. Unfortunately this solution did not worked. The client certificate was not present in the Moon browser after profile upload. After that I investigated that subject a little bit and I found that client certificates aren't normally stored in Chrome profile, but in host OS. So could you please advise, how to make working following solution "client mutual TLS authentication only requires client cert and key installed in browser profile"?

Thank you

@aandryashin
Copy link
Member

aandryashin commented May 2, 2024 via email

@slunyaak
Copy link

slunyaak commented May 2, 2024

Yes, I have added it, this is used code:

   ChromeOptions options = new ChromeOptions();

    options.setCapability("moon:options", Map.of("context", "http://WWeebbHHoosstt/profile.tar.gz"));

    options.addArguments("--user-data-dir=/home/user/profile");
    try {
        WebDriver driver = new RemoteWebDriver(new URL("http://MMoonnHHoosstt/wd/hub"), options);
    } catch (MalformedURLException e){

    }

@aandryashin
Copy link
Member

aandryashin commented May 2, 2024 via email

@slunyaak
Copy link

slunyaak commented May 3, 2024

Hi, thank you!, Uploading /home/user/.pki with imported client certificate using Moon context feature was the right solution.

@vania-pooh
Copy link
Member

@slunyaak so this is now resolved, right?

@slunyaak
Copy link

@vania-pooh Hi, uploading certificate works perfectly, thanks! But now we are facing new issue with confirming certificate selection in Chrome browser running in Moon. We have imported there just one certificate , but we have issue making Selenide to click on "OK" button in order to confirm certificate selection. We have tried to resolve that by defaulting certificate using AutoSelectCertificateForUrls, but required directories for storing auto_select_certificate.json in pod cannot be located. Could you please advice, how to solve it?

@vania-pooh
Copy link
Member

@slunyaak this seems to be your project specific issue. Please provide more details on what should be clicked, e.g. a screenshot.

@slunyaak
Copy link

slunyaak commented Aug 21, 2024

So this is screenshot from test, where I am required to confirm certificate selection in Moon's Chrome:
image

@vania-pooh
Copy link
Member

@aandryashin any ideas?

@aandryashin
Copy link
Member

aandryashin commented Aug 21, 2024 via email

@slunyaak
Copy link

My colleague has unsuccessfully tried couple of these following approaches:

A.
Selenide.confirm("OK");

B.
Selenide.confirm();

C.
Selenide.switchTo().alert().accept();

D.
RobotWriter robotWriter = new RobotWriter();
robotWriter.tab();
robotWriter.tab();
robotWriter.tab();
robotWriter.enter();

What is please your suggestion?

@aandryashin
Copy link
Member

aandryashin commented Aug 21, 2024 via email

@phillwhite
Copy link

We've tried to use the Actions class from Selenium for pressing the TAB and ENTER keys to confirm the popup, but without success. From several discussions on Stackoverflow, it seems to me that this is an OS popup and therefore it cannot be confirmed even using pure Selenium. Do you have any other suggestions for us @aandryashin?

@aandryashin
Copy link
Member

aandryashin commented Sep 2, 2024 via email

@aandryashin
Copy link
Member

aandryashin commented Sep 5, 2024 via email

@vania-pooh vania-pooh changed the title Question: Is there a way to import client certificate to pod Automatically select client certificate in Chrome Sep 6, 2024
@vania-pooh vania-pooh added this to the 2.7.2 milestone Sep 6, 2024
@vania-pooh
Copy link
Member

vania-pooh commented Sep 6, 2024

Need to document autoSelectClientCerts=true capability and Firefox pref value.

@aandryashin
Copy link
Member

aandryashin commented Sep 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants