-
Notifications
You must be signed in to change notification settings - Fork 82
Support custom hostname and TLS options #2588
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d919b9b
Support custom hostname and TLS options
Wdestroier ce514f5
Format webdev_server.dart file
Wdestroier 3c6a95f
TLS options E2E tests
Wdestroier 2dd1c26
Merge branch 'main' into main
Wdestroier 1f2a782
Add copyright header and remove duplicated files
Wdestroier 0bd7242
Merge branch 'main' of https://github.com/Wdestroier/webdev
Wdestroier f30b610
Merge branch 'main' into main
bkonyi ec04794
Format test/tls_test.dart
Wdestroier df0ec78
Merge branch 'main' of https://github.com/Wdestroier/webdev
Wdestroier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDR8FlEhQ8XZctL | ||
mGdx78Z5EInK2mcfU9Nq4oUKkPeiql7Sd3cd3prd+m5MYylL255wAZf8Fdupkko2 | ||
cjQEsU24jUBWVG5q3YqZ+OidFYdxYnPbDhFtzL3Lr2zHGAi+MgqVENUF6ED2O5tU | ||
9U1crceXmXHb3E8Sg+zXX6TMVCS11OH9VQ1ZutM0fFMPZxmfU5aOfd5kuTmTiaOt | ||
OMyymroUPgzRW6UcbLfSdD7KuNFQgHDHiWkr2MtoZffgGM/cOfmCdgE85MdL6kyb | ||
7TUTbAl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hDrtuztyTNdi4ekJdK | ||
ceEHoB3GniGBLJs13JgrabocpVpYUXYlEwLXijfOFmYGy1u2NViFq5dDIvSxCg1X | ||
yzwLI0GmcCSoq1bB5lO8Juw95skLdexmEdDoYfH+gQKBgDgaFlF9lYuKd0HhAxxm | ||
oJ8WBv26FWxR8/UsvUPqI8Mzmb8J1Q22tZEMEVr8bN/HkcL+8DVQ4uh2zx9+rqC0 | ||
aPqJZNgePGpRDhZ/cwA8xsg+Xkou8rrFjpGRuVuG9FvMEexufkHoDc94ppONuwsR | ||
QzjTUxgXdLjtxT95ISwX83Nr | ||
-----END PRIVATE KEY----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIEgjCCAuqgAwIBAgIQBeTmjjlnyrCQUy06Xx/ybzANBgkqhkiG9w0BAQsFADCB | ||
pTEeMBwGA1UEChMVbWtjZXJ0IGRldmVsb3BtZW50IENBMT0wOwYDVQQLDDRMQVBU | ||
T1AtQUFSSFFPMkxcV2Rlc3RATEFQVE9QLUFBUkhRTzJMIChXYWduZXIgRC4gRi4p | ||
MUQwQgYDVQQDDDtta2NlcnQgTEFQVE9QLUFBUkhRTzJMXFdkZXN0QExBUFRPUC1B | ||
QVJIUU8yTCAoV2FnbmVyIEQuIEYuKTAeFw0yNTAyMTQxNDI2MjFaFw0yNzA1MTQx | ||
NDI2MjFaMGgxJzAlBgNVBAoTHm1rY2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0 | ||
ZTE9MDsGA1UECww0TEFQVE9QLUFBUkhRTzJMXFdkZXN0QExBUFRPUC1BQVJIUU8y | ||
TCAoV2FnbmVyIEQuIEYuKTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB | ||
ANHwWUSFDxdly0uYZ3HvxnkQ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 | ||
4Jh3TJKU | ||
-----END CERTIFICATE----- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:collection/collection.dart'; | ||
import 'package:logging/logging.dart'; | ||
import 'package:path/path.dart' as p; | ||
import 'package:test/test.dart'; | ||
import 'package:test_descriptor/test_descriptor.dart' as d; | ||
import 'package:test_process/test_process.dart'; | ||
|
||
import 'package:webdev/src/logging.dart'; | ||
import 'package:webdev/src/serve/utils.dart'; | ||
|
||
import 'test_utils.dart'; | ||
|
||
void main() { | ||
group('serve app with TLS options', () { | ||
// Change to true for debugging. | ||
final debug = false; | ||
|
||
final testRunner = TestRunner(); | ||
late String exampleDirectory; | ||
|
||
setUpAll(() async { | ||
configureLogWriter(debug); | ||
await testRunner.setUpAll(); | ||
exampleDirectory = p.absolute( | ||
p.join(p.current, '..', 'fixtures', '_experimentSound')); | ||
|
||
final process = await TestProcess.start( | ||
'dart', | ||
['pub', 'upgrade'], | ||
workingDirectory: exampleDirectory, | ||
environment: getPubEnvironment(), | ||
); | ||
|
||
await process.shouldExit(0); | ||
|
||
await d | ||
.file('.dart_tool/package_config.json', isNotEmpty) | ||
.validate(exampleDirectory); | ||
await d.file('pubspec.lock', isNotEmpty).validate(exampleDirectory); | ||
}); | ||
|
||
test('listens on a loopback interface', () async { | ||
final port = await findUnusedPort(); | ||
final args = [ | ||
'serve', | ||
'web:$port', | ||
'--hostname=0.0.0.0', | ||
'--tls-cert-chain=localhost+2.pem', | ||
'--tls-cert-key=localhost+2-key.pem', | ||
]; | ||
|
||
final process = await testRunner.runWebDev(args, | ||
workingDirectory: exampleDirectory); | ||
await expectLater(process.stdout, emitsThrough(contains('Succeeded'))); | ||
|
||
final client = HttpClient() | ||
..badCertificateCallback = (_, __, ___) => true; | ||
try { | ||
final request = | ||
await client.getUrl(Uri.parse('https://localhost:$port')); | ||
final response = await request.close(); | ||
expect(response.statusCode, equals(200)); | ||
} finally { | ||
client.close(force: true); | ||
} | ||
|
||
await process.kill(); | ||
await process.shouldExit(); | ||
}); | ||
|
||
test('listens on a non-loopback interface', () async { | ||
final port = await findUnusedPort(); | ||
final args = [ | ||
'serve', | ||
'web:$port', | ||
'--hostname=0.0.0.0', | ||
'--tls-cert-chain=localhost+2.pem', | ||
'--tls-cert-key=localhost+2-key.pem', | ||
]; | ||
|
||
final process = await testRunner.runWebDev(args, | ||
workingDirectory: exampleDirectory); | ||
await expectLater(process.stdout, emitsThrough(contains('Succeeded'))); | ||
|
||
final interfaces = await NetworkInterface.list( | ||
type: InternetAddressType.IPv4, | ||
includeLoopback: false, | ||
); | ||
final nonLoopback = interfaces.expand((i) => i.addresses).firstOrNull; | ||
|
||
if (nonLoopback == null) { | ||
Logger.root.info( | ||
'No non-loopback IPv4 address available, skipping hostname test.'); | ||
} else { | ||
final client = HttpClient() | ||
..badCertificateCallback = (_, __, ___) => true; | ||
try { | ||
final request = await client | ||
.getUrl(Uri.parse('https://${nonLoopback.address}:$port')); | ||
final response = await request.close(); | ||
expect(response.statusCode, equals(200)); | ||
} finally { | ||
client.close(force: true); | ||
} | ||
} | ||
|
||
await process.kill(); | ||
await process.shouldExit(); | ||
}); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.