Skip to content

Commit 8227034

Browse files
Merge pull request #163 from apel/release-3.2.1
Release 3.2.1 to master
2 parents bb2f026 + 35fbccf commit 8227034

File tree

9 files changed

+86
-31
lines changed

9 files changed

+86
-31
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Changelog for ssm
22
=================
3+
* Wed Apr 28 2021 Adrian Coveney <[email protected]> - 3.2.1-1
4+
- Changed certificate and key comparison to allow both RSA and EC keys.
5+
- Corrected dependencies to include OpenSSL.
6+
37
* Thu Mar 18 2021 Adrian Coveney <[email protected]> - 3.2.0-1
48
- Added logging of what certificate DNs/subjects are being used to facilitate
59
troubleshooting.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ SSM is provided by [STFC](https://stfc.ukri.org/), a part of [UK Research and In
3232
The EPEL repository must be enabled. This can be done by installing
3333
the RPM for your version of SL, which is available on this page:
3434
http://fedoraproject.org/wiki/EPEL
35+
You will also need to have the OpenSSL library installed. Other prerequisites are listed below.
3536

3637
The Python STOMP library (N.B. versions between 3.1.1 (inclusive) and 5.0.0
3738
(exclusive) are currently supported)

apel-ssm.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
%endif
55

66
Name: apel-ssm
7-
Version: 3.2.0
7+
Version: 3.2.1
88
%define releasenumber 1
99
Release: %{releasenumber}%{?dist}
1010
Summary: Secure stomp messenger
@@ -21,7 +21,7 @@ BuildArch: noarch
2121
BuildRequires: python-devel
2222
%endif
2323

24-
Requires: stomppy < 5.0.0, python-daemon, python-ldap
24+
Requires: stomppy < 5.0.0, python-daemon, python-ldap, openssl
2525
Requires(pre): shadow-utils
2626

2727
%define ssmconf %_sysconfdir/apel
@@ -100,6 +100,10 @@ rm -rf $RPM_BUILD_ROOT
100100
%doc %_defaultdocdir/%{name}
101101

102102
%changelog
103+
* Wed Apr 28 2021 Adrian Coveney <[email protected]> - 3.2.1-1
104+
- Changed certificate and key comparison to allow both RSA and EC keys.
105+
- Corrected dependencies to include OpenSSL.
106+
103107
* Thu Mar 18 2021 Adrian Coveney <[email protected]> - 3.2.0-1
104108
- Added logging of what certificate DNs/subjects are being used to facilitate
105109
troubleshooting.

migrating_to_ams.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
# Migrating from using EGI ActiveMQ Message Brokers to using EGI ARGO Messaging Service
22

3+
## Prerequisites for using AMS
4+
5+
- A valid host certificate from an IGTF Accredited CA.
6+
- A GOCDB 'Site' entry flagged as 'Production'.
7+
- A GOCDB 'Service' entry of the correct service type flagged as 'Production'. The following service types are used:
8+
- For Grid accounting use 'gLite-APEL'.
9+
- For Cloud accounting use 'eu.egi.cloud.accounting'.
10+
- For Storage accounting use 'eu.egi.storage.accounting'.
11+
- The 'Host DN' listed in the GOCDB 'Service' entry must exactly match the certificate DN of the host used for accounting. Make sure there are no leading or trailing spaces in the 'Host DN' field.
12+
- Messages sent via AMS must be below 1 Megabyte in size, and the messaging service is optimised around this limit. If your messages start hitting this limit when using SSM, see the advice at the bottom of this document.
13+
14+
## Software requirements
15+
316
Migration requires upgrading APEL SSM to at least version 2.4.0, installing the ARGO AMS Library, and adding new values to your configuration.
417

518
The ARGO AMS Library is available in UMD as `python-argo-ams-library`. Versions above 0.5.0 are recommended.
619

7-
## Sender
20+
## Configuration changes
21+
22+
### Sender
823

924
The sender configuration is usually found under `/etc/apel/sender.cfg`. Follow the steps below to migrate.
1025

@@ -42,11 +57,30 @@ The next time `ssmsend` runs it should be using the AMS. You can check this by l
4257
2018-09-19 14:18:07,862 - ssmsend - INFO - ========================================
4358
```
4459

45-
## Receiver
60+
### Receiver
61+
62+
This is only used for the central Accounting Repository, Accounting Portal, and regional accounting servers.
4663

4764
1. Follow the steps 1 to 4 as per the [Sender documentation](#Sender) but editing your receiver configuration instead, usually found under `/etc/apel/receiver.cfg`, naming the section `[receiver]` rather than `[sender]`.
4865
1. Change `destination` to be the subscription you are using to pull messages down.
4966
1. Add your token to the `[messaging]` section of your configuration:
5067
```
5168
token: your_token_here
5269
```
70+
71+
## Issues
72+
73+
### Messages too large
74+
75+
- Cloud sites using cASO should ensure they are using at least version 1.4.0 of cASO as this version limits the number of records in a message.
76+
- Grid sites using the APEL accounting client need to be using APEL 1.9.0 and SSM 3.2.0. They can then modify their APEL client script, usually located at `/usr/bin/apelclient`. At the moment, this requires a manual change, but will become a configuration option in the next version of APEL. For example, to halve the number of records per message from the default of 1000, add the line `unloader.records_per_message = 500` after the call to `DbUnloader`:
77+
```
78+
@@ -233,6 +233,7 @@ def run_client(ccp):
79+
80+
unloader = DbUnloader(db, unload_dir, include_vos, exclude_vos,
81+
local_jobs, withhold_dns)
82+
+ unloader.records_per_message = 500
83+
try:
84+
if interval == 'latest':
85+
msgs, recs = unloader.unload_latest(table_name, send_ur)
86+
```

scripts/ssm-build-deb.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
set -eu
1818

19-
TAG=3.2.0-1
19+
TAG=3.2.1-1
2020

2121
SOURCE_DIR=~/debbuild/source
2222
BUILD_DIR=~/debbuild/build
@@ -58,6 +58,7 @@ fpm -s python -t deb \
5858
--depends python-ldap \
5959
--depends libssl-dev \
6060
--depends libsasl2-dev \
61+
--depends openssl \
6162
--deb-changelog $SOURCE_DIR/ssm-$TAG/CHANGELOG \
6263
--python-install-bin /usr/bin \
6364
--python-install-lib $PYTHON_INSTALL_LIB \

scripts/ssm-build-rpm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
rpmdev-setuptree
1111

1212
RPMDIR=/home/rpmb/rpmbuild
13-
VERSION=3.2.0-1
13+
VERSION=3.2.1-1
1414
SSMDIR=apel-ssm-$VERSION
1515

1616
# Remove old sources and RPMS

ssm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import logging
2020
import sys
2121

22-
__version__ = (3, 2, 0)
22+
__version__ = (3, 2, 1)
2323

2424
LOG_BREAK = '========================================'
2525

ssm/crypto.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,23 @@ def check_cert_key(certpath, keypath):
6363
if cert == key:
6464
return False
6565

66-
p1 = Popen(['openssl', 'x509', '-noout', '-modulus'],
66+
p1 = Popen(['openssl', 'x509', '-pubkey', '-noout'],
6767
stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
68-
modulus1, error = p1.communicate(cert)
68+
pubkey1, error = p1.communicate(cert)
6969

7070
if error != '':
7171
log.error(error)
7272
return False
7373

74-
p2 = Popen(['openssl', 'rsa', '-noout', '-modulus'],
74+
p2 = Popen(['openssl', 'pkey', '-pubout'],
7575
stdin=PIPE, stdout=PIPE, stderr=PIPE, universal_newlines=True)
76-
modulus2, error = p2.communicate(key)
76+
pubkey2, error = p2.communicate(key)
7777

7878
if error != '':
7979
log.error(error)
8080
return False
8181

82-
return modulus1.strip() == modulus2.strip()
83-
82+
return pubkey1.strip() == pubkey2.strip()
8483

8584
def sign(text, certpath, keypath):
8685
"""Sign the message using the certificate and key in the files specified.

test/test_crypto.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import os
66
from subprocess import call, Popen, PIPE
7+
import tempfile
78
import quopri
89

910
from ssm.crypto import check_cert_key, \
@@ -59,24 +60,35 @@ def tearDown(self):
5960
os.remove(self.ca_certpath)
6061

6162
def test_check_cert_key(self):
62-
'''
63-
This will print an error log message for the tests that are
64-
supposed to fail; you can ignore it.
65-
'''
66-
67-
# One version of the method would have passed this, because of the
68-
# way it checked for validity.
69-
try:
70-
if check_cert_key('hello', 'hello'):
71-
self.fail('Accepted non-existent cert and key.')
72-
except CryptoException:
73-
pass
74-
75-
if check_cert_key(TEST_CERT_FILE, TEST_CERT_FILE):
76-
self.fail('Accepted certificate as key.')
77-
78-
if not check_cert_key(TEST_CERT_FILE, TEST_KEY_FILE):
79-
self.fail('Cert and key match but function failed.')
63+
"""Check that valid cert and key works."""
64+
self.assertTrue(check_cert_key(TEST_CERT_FILE, TEST_KEY_FILE),
65+
'Cert and key match but function failed.')
66+
67+
def test_check_cert_key_invalid_paths(self):
68+
"""Check invalid file paths don't return True."""
69+
self.assertFalse(check_cert_key('hello', 'hello'),
70+
'Accepted invalid file paths.')
71+
self.assertFalse(check_cert_key(TEST_CERT_FILE, 'k'),
72+
'Accepted invalid key path.')
73+
self.assertFalse(check_cert_key('c', TEST_KEY_FILE),
74+
'Accepted invalid cert path.')
75+
76+
def test_check_cert_key_arg_order(self):
77+
"""Check incorrect order of cert and key path args doesn't succeed."""
78+
self.assertFalse(check_cert_key(TEST_CERT_FILE, TEST_CERT_FILE),
79+
'Accepted certificate as key.')
80+
self.assertFalse(check_cert_key(TEST_KEY_FILE, TEST_KEY_FILE),
81+
'Accepted key as cert.')
82+
self.assertFalse(check_cert_key(TEST_KEY_FILE, TEST_CERT_FILE),
83+
'Accepted key and cert wrong way round.')
84+
85+
def test_check_cert_key_invalid_files(self):
86+
"""Check behaviour with an invalid cert or key file."""
87+
with tempfile.NamedTemporaryFile() as tmp:
88+
self.assertFalse(check_cert_key(tmp.name, TEST_KEY_FILE),
89+
'Accepted invalid cert file.')
90+
self.assertFalse(check_cert_key(TEST_CERT_FILE, tmp.name),
91+
'Accepted invalid key file.')
8092

8193
def test_sign(self):
8294
'''

0 commit comments

Comments
 (0)