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

Update server.py ssl wrapping #1633

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/functional/only_in_ci_system/add-client-certificate.bats
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ setup_file() {

teardown_file() {

# Skip this test for local development because it takes a long time. To run this test locally,
# configure swupd with --with-fallback-capaths=<path to top level of repo>/swupd_test_certificates
# and run: RUNNING_IN_CI=true make check
if [ -z "${RUNNING_IN_CI}" ]; then
return
fi

destroy_test_environment --force "$TEST_NAME"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ setup_file() {

teardown_file() {

# Skip this test for local development because it takes a long time. To run this test locally,
# configure swupd with --with-fallback-capaths=<path to top level of repo>/swupd_test_certificates
# and run: RUNNING_IN_CI=true make check
if [ -z "${RUNNING_IN_CI}" ]; then
return
fi

destroy_test_environment --force "$TEST_NAME"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ setup_file() {

teardown_file() {

# Skip this test for local development because it takes a long time. To run this test locally,
# configure swupd with --with-fallback-capaths=<path to top level of repo>/swupd_test_certificates
# and run: RUNNING_IN_CI=true make check
if [ -z "${RUNNING_IN_CI}" ]; then
return
fi

destroy_test_environment --force "$TEST_NAME"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ setup_file() {

teardown_file() {

# Skip this test for local development because it takes a long time. To run this test locally,
# configure swupd with --with-fallback-capaths=<path to top level of repo>/swupd_test_certificates
# and run: RUNNING_IN_CI=true make check
if [ -z "${RUNNING_IN_CI}" ]; then
return
fi

destroy_test_environment --force "$TEST_NAME"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ setup_file() {

teardown_file() {

# Skip this test for local development because it takes a long time. To run this test locally,
# configure swupd with --with-fallback-capaths=<path to top level of repo>/swupd_test_certificates
# and run: RUNNING_IN_CI=true make check
if [ -z "${RUNNING_IN_CI}" ]; then
return
fi

destroy_test_environment --force "$TEST_NAME"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ setup_file() {

teardown_file() {

# Skip this test for local development because it takes a long time. To run this test locally,
# configure swupd with --with-fallback-capaths=<path to top level of repo>/swupd_test_certificates
# and run: RUNNING_IN_CI=true make check
if [ -z "${RUNNING_IN_CI}" ]; then
return
fi

destroy_test_environment --force "$TEST_NAME"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ setup_file() {

teardown_file() {

# Skip this test for local development because it takes a long time. To run this test locally,
# configure swupd with --with-fallback-capaths=<path to top level of repo>/swupd_test_certificates
# and run: RUNNING_IN_CI=true make check
if [ -z "${RUNNING_IN_CI}" ]; then
return
fi

destroy_test_environment --force "$TEST_NAME"

}
Expand Down
15 changes: 6 additions & 9 deletions test/functional/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,16 +266,13 @@ def parse_arguments():

# configure ssl certificates
if args.server_cert and args.server_key:
wrap_socket_args = {"certfile": args.server_cert,
"keyfile": args.server_key,
"server_side": True}

# add client certificate
wrap_socket_args = {"server_side": True}
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(args.server_cert, args.server_key)
if args.client_cert:
wrap_socket_args.update({"ca_certs": args.client_cert,
"cert_reqs": ssl.CERT_REQUIRED})

httpd.socket = ssl.wrap_socket(httpd.socket, **wrap_socket_args)
context.load_verify_locations(cafile=args.client_cert)
context.verify_mode = ssl.CERT_REQUIRED
httpd.socket = context.wrap_socket(httpd.socket, **wrap_socket_args)

# invalid certificate combination
elif args.server_cert or args.server_key or args.client_cert:
Expand Down
Loading