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(dart_frog_cli): running on message not showing https when providing a security context #1074

Open
alestiago opened this issue Sep 25, 2023 · 4 comments
Labels
bug Something isn't working as expected

Comments

@alestiago
Copy link
Contributor

alestiago commented Sep 25, 2023

Description

When running a Dart Frog server that uses a securityContext the CLI outputs an erroneous message.

Upon secure serving the output should be "Running on https://..." instead of "Running on "http://...".

Steps To Reproduce

  1. Create a Dart Frog project:
dart_frog create sample
  1. Add a secure entry point (sample/main.dart):
import 'dart:io';

import 'package:dart_frog/dart_frog.dart';

Future<HttpServer> run(Handler handler, InternetAddress ip, int port) {
  final chain =
      Platform.script.resolve('certificates/server_chain.pem').toFilePath();
  final key =
      Platform.script.resolve('certificates/server_key.pem').toFilePath();

  final securityContext = SecurityContext()
    ..useCertificateChain(chain)
    ..usePrivateKey(key, password: 'dartdart');

  return serve(handler, ip, port, securityContext: securityContext);
}
  1. Download the server_chain.pem and server_key.pem from this Dart tutorial and save on sample/.dart_frog/certificates
  2. Start the server through the CLI (from sample/):
dart_frog dev --port=8070
  1. Observe that the CLI outputs "http://localhost/8070", opening such shows a ERR_EMPTY_RESPONSE.
  2. Observe that accessing "https://localhost:8070" does respond.

Expected Behavior

The CLI message should output something as: "Running on https:localhost:8080" when the server is using a custom entry point that provides a valid securityContext.

@alestiago alestiago added the bug Something isn't working as expected label Sep 25, 2023
@dhruvpatidar359
Copy link

Hi @alestiago , I ran thorugh a lot of files and figured out that we just have to know whether this is a secure or not . The final thing that we have to change is dart_frog_cli . But How can we get to that the user has provided the secuirtyContext and it is good and working . I have files like daemon_server.dart , i am just trying to look how the port and ip address from main are passing to the server . May you please help where to start with this.

@alestiago
Copy link
Contributor Author

alestiago commented Nov 15, 2023

(cc: @renancaraujo -- I think you're working on a refactor that might be touching these files/structure)

@dhruvpatidar359
Copy link

@renancaraujo may please guide me in this particular issue ? Which files i have to tickle with .

@renancaraujo
Copy link
Contributor

@dhruvpatidar359 Writing a detailed guide to this would be as long as tackling the solution, I can summarize:

  • The condition to show the correct protocol in the message should come from the existence of a secure context on the running server, this can be defined in the hook of the devserver brick.
  • This condition has to be communicated back to the CLI somehow.

This is not a beginner-friendly issue, BTW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
Status: Backlog
Development

No branches or pull requests

3 participants