Skip to content

Commit faf0c43

Browse files
authored
Merge pull request #81 from brianhlin/SOFTWARE-5668.incommon-config-file
Fix bug with config file defaults
2 parents 77d3013 + 77cbe03 commit faf0c43

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

config/ca-issuer.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[InCommon]
2-
organization:
3-
department:
2+
organization: 9697
3+
department: 9732
44
customeruri: InCommon
55
igtfservercert: 20583
66
igtfmultidomain: 20812

osgpkitools/incommon_request.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ def parse_cli():
8282
optional.add_argument('-a', '--altname', action='append', dest='altnames', default=[],
8383
help='Specify the SAN for the requested certificate (only works with -H/--hostname). '
8484
'May be specified more than once for additional SANs.')
85-
optional.add_argument('-C', '--config', action='store', dest='config_file', default='/etc/osg/pki/ca-issuer.conf'
86-
'Path to configuration file')
85+
optional.add_argument('-C', '--config', action='store', dest='config_file', default='/etc/osg/pki/ca-issuer.conf',
86+
help='Path to configuration file')
8787
optional.add_argument('-d', '--directory', action='store', dest='write_directory', default='.',
8888
help="The directory to write the host certificate(s) and key(s)")
89-
optional.add_argument('-O', '--orgcode', action='store', dest='orgcode', default='9697,9732', metavar='ORG,DEPT',
89+
optional.add_argument('-O', '--orgcode', action='store', dest='orgcode', metavar='ORG,DEPT',
9090
help='Organization and Department codes for the InCommon Certificate Service. Defaults are Fermilab\'s codes.')
9191
optional.add_argument('-l', '--key-length', action='store', default=cert_utils.Csr.KEY_LENGTH,
9292
type=int, help='The key size to generate')
@@ -132,6 +132,12 @@ def __call__(self, parser, namespace, values, option_string=None):
132132
raise IOError(f"Unable to read the file at: {values}")
133133

134134

135+
def fail(message):
136+
"""Immediately fail with the specified message
137+
"""
138+
sys.exit(message)
139+
140+
135141
def build_headers(config):
136142
""""This function build the headers for the HTTP request.
137143
Returns headers for the HTTP request
@@ -269,9 +275,20 @@ def main():
269275
args = parse_cli()
270276

271277
config_parser = configparser.ConfigParser()
272-
config_parser.read(args.config_file)
273-
CONFIG = dict(config_parser.items('InCommon'))
274-
278+
try:
279+
with open(args.config_file, 'r', encoding='utf-8') as config_file:
280+
try:
281+
config_parser.read_file(config_file)
282+
except configparser.Error as exc:
283+
fail(exc)
284+
except OSError as exc:
285+
fail(exc)
286+
287+
try:
288+
CONFIG = dict(config_parser.items('InCommon'))
289+
except configparser.NoSectionError:
290+
fail(f'Could not find [InCommon] section header in {args.config_file}')
291+
275292
if args.orgcode:
276293
codes = [code.strip() for code in args.orgcode.split(',')]
277294
CONFIG['organization'] = codes[0]

osgpkitools/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from .ExceptionDefinitions import *
99

10-
VERSION_NUMBER = "3.5.1"
10+
VERSION_NUMBER = "3.6.1"
1111
HELP_EMAIL = 'help@opensciencegrid.org'
1212

1313

rpm/osg-pki-tools.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Summary: osg-pki-tools
22
Name: osg-pki-tools
3-
Version: 3.6.0
3+
Version: 3.6.1
44
Release: 1%{?dist}
55
Source: osg-pki-tools-%{version}.tar.gz
66
License: Apache 2.0
@@ -43,6 +43,10 @@ mv %{buildroot}/%{_prefix}/config/ca-issuer.conf %{buildroot}%{_sysconfdir}/osg/
4343
%config(noreplace) %{_sysconfdir}/osg/pki/ca-issuer.conf
4444

4545
%changelog
46+
* Wed Sep 6 2023 Brian Lin <blin@cs.wisc.edu> - 3.6.1
47+
- Fix bug with default CA config file option (SOFTWARE-5668)
48+
- Update default InCommon IGTF CA IDs to point to CA 3
49+
4650
* Fri Sep 1 2023 Brian Lin <blin@cs.wisc.edu> - 3.6.0
4751
- Add configuration file for osg-incommon-cert-request (SOFTWARE-5668)
4852
- Update default CSR key length to 4096, add CLI option (SOFTWARE-5651)

0 commit comments

Comments
 (0)