Skip to content

Option to explicitly enable or disable optional client certificates #1138

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 1 commit into from
Aug 14, 2022
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
13 changes: 11 additions & 2 deletions src/main/distrib/data/defaults.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2059,8 +2059,8 @@ server.storePassword = gitblit
# authenticate with ssl certificates. If enabled, only https clients with the
# a valid client certificate will be able to access Gitblit.
#
# If disabled, client certificate authentication is optional and will be tried
# first before falling-back to form authentication or basic authentication.
# If disabled, optional client certificate authentication is configurable by
# server.wantClientCertificates
#
# Requiring client certificates to access any of Gitblit may be too extreme,
# consider this carefully.
Expand All @@ -2069,6 +2069,15 @@ server.storePassword = gitblit
# RESTART REQUIRED
server.requireClientCertificates = false

# If enabled, client certificate authentication is optional and will be tried
# first before falling-back to form authentication or basic authentication.
#
# If disabled, no client certificate authentication will be done at all.
#
# SINCE 1.8.1
# RESTART REQUIRED
server.wantClientCertificates = false

# Port for shutdown monitor to listen on.
#
# SINCE 0.5.0
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/gitblit/GitBlitServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void log(String message) {
if (params.requireClientCertificates) {
factory.setNeedClientAuth(true);
} else {
factory.setWantClientAuth(true);
factory.setWantClientAuth((params.wantClientCertificates));
}

ServerConnector connector = new ServerConnector(server, factory);
Expand Down Expand Up @@ -597,6 +597,9 @@ public static class Params {
@Option(name = "--requireClientCertificates", usage = "Require client X509 certificates for https connections.")
public Boolean requireClientCertificates = FILESETTINGS.getBoolean(Keys.server.requireClientCertificates, false);

@Option(name = "--wantClientCertificates", usage = "Ask for optional client X509 certificate for https connections. Ignored if client certificates are required.")
public Boolean wantClientCertificates = FILESETTINGS.getBoolean(Keys.server.wantClientCertificates, false);

/*
* Setting overrides
*/
Expand Down