Skip to content
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

fix: failed to establish a connection with the upstream server #263

Merged
merged 6 commits into from
Oct 22, 2024

Conversation

cristianoventura
Copy link
Collaborator

Description

This PR adds a new field in settings to allow users to input the certificate file (pem, p12 or cer) so a trusted connection can be established with the upstream server if it requires SSL.

How to Test

In your local dev environment, there is a directory in resources/certificates. This directory will be used to initialize a new instance of mitmproxy for testing purposes.

Launch a new instance of mitmproxy with SSL configured, pointing the certificate folder to your local environment.

$ mitmdump --mode regular@7000 --set confdir=/path/to/k6-studio/resources/certificates

Happy path:

  • In k6 Studio, go to Settings and set the proxy to be upstream and point to the other instance of mitmproxy
  • In "Certificate path", select the mitmproxy-ca-cert.pem (for macOS) or mitmproxy-ca-cert.p12 (for Windows) from the certificates folder
  • Save settings, wait for the proxy to restart, and start a new recording
  • Browse some sites with HTTPS successfully

Sad path:

  • In k6 Studio, go to Settings and clear the "Certificate path" input
  • Save settings, wait for the proxy to restart, and start a new recording
  • Browse some sites with HTTPS with error

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (npm run lint) and all checks pass.
  • I have run tests locally (npm test) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Screenshots (if appropriate):

image

Related PR(s)/Issue(s)

Resolves #260

@cristianoventura cristianoventura self-assigned this Oct 21, 2024
@cristianoventura cristianoventura requested a review from a team as a code owner October 21, 2024 17:57
@cristianoventura cristianoventura requested review from going-confetti and Llandy3d and removed request for a team October 21, 2024 17:57
onSelectFile: () => void
}

export const FileUploadInput = ({
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extracted this file into its own component so it can be reused for the recorder's Browser Path as well

@Llandy3d
Copy link
Member

I think I encountered a bug, after following the happy path by checking the settings again it was presented as regular while the file on disk did indeed still include the correct proxy config. (A restart fixed it but we might want to look into it)

image

Llandy3d
Llandy3d previously approved these changes Oct 22, 2024
Copy link
Member

@Llandy3d Llandy3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

@@ -72,9 +68,7 @@ export const SettingsDialog = ({ open, onOpenChange }: SettingsDialogProps) => {

<Flex gap="3" justify="end">
<Dialog.Close>
<Button variant="outline" onClick={handleCancelClick}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I encountered a bug, after following the happy path by checking the settings again it was presented as regular while the file on disk did indeed still include the correct proxy config. (A restart fixed it but we might want to look into it)

@Llandy3d there was a leftover logic from when Settings was still a page and the form state needed to be reset. This should fix the issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did 🥳

@cristianoventura cristianoventura merged commit 7a9480e into main Oct 22, 2024
2 checks passed
@cristianoventura cristianoventura deleted the feat/proxy-upstream-certificate branch October 22, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to establish a connection with the upstream server
2 participants