Skip to content

Commit 0c4cbb6

Browse files
authored
Merge pull request #2 from atomicturtle/fix-02
Fixes for SSL support and signing workflow
2 parents 0f08f13 + e959cd2 commit 0c4cbb6

14 files changed

Lines changed: 461 additions & 301 deletions

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
__pycache__/
2+
*.py[cod]
3+
*$py.class
4+
.pytest_cache/
5+
.coverage
6+
htmlcov/
7+
.venv/
8+
venv/
9+
ENV/
10+
.env
11+
.chelon/certs/
12+
*.tar.gz

chelon.spec

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: chelon
22
Version: 1.0.0
3-
Release: 2%{?dist}
3+
Release: 3%{?dist}
44
Summary: Remote GPG package signing service
55

66
License: GPL-2.0-or-later
@@ -82,8 +82,7 @@ install -m 644 server/audit.py %{buildroot}%{_datadir}/%{name}/server/
8282
install -m 755 tools/chelon-admin %{buildroot}%{_bindir}/
8383

8484
# Install client tools
85-
install -m 755 tools/chelon-sign-rpm %{buildroot}%{_bindir}/
86-
install -m 755 tools/chelon-sign-repomd %{buildroot}%{_bindir}/
85+
install -m 755 tools/chelon-sign %{buildroot}%{_bindir}/
8786
install -m 644 tools/chelon_client.py %{buildroot}%{_datadir}/%{name}/client/
8887

8988
# Install systemd unit
@@ -133,11 +132,17 @@ fi
133132

134133
%files client
135134
%doc README.md
136-
%{_bindir}/chelon-sign-rpm
137-
%{_bindir}/chelon-sign-repomd
135+
%{_bindir}/chelon-sign
138136
%{_datadir}/%{name}/client/
139137

140138
%changelog
139+
* Wed Jan 07 2026 Atomicorp <support@atomicorp.com> - 1.0.0-3
140+
- Consolidate chelon-sign-rpm and chelon-sign-repomd into chelon-sign
141+
- Security: Sanitize script paths in RPM macros
142+
- Security: Optimize DoS protection with chunked reading
143+
- Fix: Add error handling for malformed base64 signatures
144+
- Fix: Improve client certificate fallback logic
145+
141146
* Wed Jan 07 2026 Atomicorp <support@atomicorp.com> - 1.0.0-2
142147
- Split into server and client subpackages
143148
- Add client signing tools (chelon-sign-rpm, chelon-sign-repomd)

docs/USAGE.md

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ scp /etc/chelon/certs/chelon_ca.crt ~/.chelon/certs/
3838
### Sign an RPM
3939

4040
```bash
41-
# Sign a single RPM
42-
chelon-sign-rpm package.rpm
41+
# Sign a single RPM (detached signature)
42+
chelon-sign package.rpm
43+
44+
# Embed signature into RPM header (Integrated Signing)
45+
# This allows 'rpm -K' to work natively
46+
chelon-sign --resign package.rpm
4347

4448
# Specify key type
45-
chelon-sign-rpm --key-type legacy package.rpm
49+
chelon-sign --key-type legacy package.rpm
4650

4751
# Sign multiple RPMs
4852
for rpm in *.rpm; do
49-
chelon-sign-rpm "$rpm"
53+
chelon-sign "$rpm"
5054
done
5155
```
5256

@@ -71,11 +75,14 @@ Signature saved to: /tmp/tmp.xyz123
7175
### Sign Repository Metadata
7276

7377
```bash
74-
# Sign repomd.xml
75-
chelon-sign-repomd repodata/repomd.xml
78+
# Sign repomd.xml (auto-detects type)
79+
chelon-sign repodata/repomd.xml
80+
81+
# Explicitly specify type
82+
chelon-sign --type repodata repodata/repomd.xml
7683

7784
# Specify key type
78-
chelon-sign-repomd --key-type modern repodata/repomd.xml
85+
chelon-sign --key-type modern repodata/repomd.xml
7986
```
8087

8188
**Output:**
@@ -222,11 +229,11 @@ sign_packages:
222229

223230
# Sign all RPMs
224231
- for rpm in dist/*.rpm; do
225-
chelon-sign-rpm "$rpm"
232+
chelon-sign "$rpm"
226233
done
227234

228235
# Sign repository metadata
229-
- chelon-sign-repomd dist/repodata/repomd.xml
236+
- chelon-sign dist/repodata/repomd.xml
230237
```
231238
232239
### Makefile Example
@@ -237,10 +244,10 @@ RPMS := $(wildcard dist/*.rpm)
237244
sign: $(RPMS)
238245
@for rpm in $(RPMS); do \
239246
echo "Signing $$rpm..."; \
240-
chelon-sign-rpm $$rpm || exit 1; \
247+
chelon-sign $$rpm || exit 1; \
241248
done
242249
@echo "Signing repository metadata..."
243-
@chelon-sign-repomd dist/repodata/repomd.xml
250+
@chelon-sign dist/repodata/repomd.xml
244251

245252
.PHONY: sign
246253
```
@@ -257,13 +264,13 @@ CHELON_TOKEN="${CHELON_TOKEN:?CHELON_TOKEN not set}"
257264
# Sign all RPMs in directory
258265
for rpm in "$1"/*.rpm; do
259266
echo "Signing: $rpm"
260-
chelon-sign-rpm "$rpm"
267+
chelon-sign "$rpm"
261268
done
262269

263270
# Sign repository metadata
264271
if [ -f "$1/repodata/repomd.xml" ]; then
265272
echo "Signing repository metadata"
266-
chelon-sign-repomd "$1/repodata/repomd.xml"
273+
chelon-sign "$1/repodata/repomd.xml"
267274
fi
268275

269276
echo "All packages signed successfully"
@@ -308,10 +315,10 @@ curl -k https://gamera:5050/api/v1/keys
308315

309316
```bash
310317
# Modern key (default)
311-
chelon-sign-rpm package.rpm
318+
chelon-sign package.rpm
312319

313320
# Legacy key (explicit)
314-
chelon-sign-rpm --key-type legacy package.rpm
321+
chelon-sign --key-type legacy package.rpm
315322
```
316323

317324
---
@@ -418,15 +425,15 @@ sudo firewall-cmd --list-all | grep 5050
418425
# Sign all RPMs in parallel (careful with rate limits)
419426

420427
find dist/ -name "*.rpm" | \
421-
xargs -P 4 -I {} chelon-sign-rpm {}
428+
xargs -P 4 -I {} chelon-sign {}
422429
```
423430

424431
### Conditional Signing
425432

426433
```bash
427434
# Only sign if not already signed
428435
if ! rpm -K package.rpm | grep -q "pgp"; then
429-
chelon-sign-rpm package.rpm
436+
chelon-sign package.rpm
430437
fi
431438
```
432439

-5.34 KB
Binary file not shown.
-9.78 KB
Binary file not shown.
-11.1 KB
Binary file not shown.
-4.46 KB
Binary file not shown.

server/auth.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,16 @@ def validate_token(self, token: str) -> Dict:
151151

152152
token_id, secret = token.split(':', 1)
153153

154-
# Check if token exists
154+
# Check if token exists, reload if not found (to handle new tokens without restart)
155155
if token_id not in self.tokens:
156-
raise ValueError(f"Unknown token: {token_id}")
156+
with self._lock:
157+
# Double-check inside lock
158+
if token_id not in self.tokens:
159+
logger.info(f"Token {token_id} not found in memory, reloading from {self.tokens_file}")
160+
self.tokens = self._load_tokens()
161+
# After reloading, immediately check if the token now exists
162+
if token_id not in self.tokens:
163+
raise ValueError(f"Unknown token after reload: {token_id}")
157164

158165
token_info = self.tokens[token_id]
159166

server/chelon-service.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,23 @@ def sign_repodata():
357357

358358
if __name__ == '__main__':
359359
# Run the Flask app
360-
host = os.environ.get('CHELON_HOST', '127.0.0.1')
361-
port = int(os.environ.get('CHELON_PORT', 5050))
360+
# Prioritize config file over environment variables
361+
host = config.get('CHELON_HOST') or os.environ.get('CHELON_HOST', '127.0.0.1')
362+
port = int(config.get('CHELON_PORT') or os.environ.get('CHELON_PORT') or 5050)
362363

363364
logger.info(f"Starting Chelon service on {host}:{port}")
364365

365-
# SSL/TLS Configuration
366-
ssl_cert = os.environ.get('CHELON_SSL_CERT')
367-
ssl_key = os.environ.get('CHELON_SSL_KEY')
368-
ssl_ca = os.environ.get('CHELON_SSL_CA')
369-
verify_client = os.environ.get('CHELON_VERIFY_CLIENT', 'false').lower() == 'true'
366+
# SSL/TLS Configuration - Prefer config file, fall back to environment
367+
ssl_cert = config.get('CHELON_SSL_CERT') or os.environ.get('CHELON_SSL_CERT')
368+
ssl_key = config.get('CHELON_SSL_KEY') or os.environ.get('CHELON_SSL_KEY')
369+
ssl_ca = config.get('CHELON_SSL_CA') or os.environ.get('CHELON_SSL_CA')
370+
371+
# Support both names for backward compatibility/consistency
372+
# Precedence: config['CHELON_SSL_VERIFY_CLIENT'] > config['CHELON_VERIFY_CLIENT'] > env['CHELON_VERIFY_CLIENT']
373+
verify_client_val = (config.get('CHELON_SSL_VERIFY_CLIENT') or
374+
config.get('CHELON_VERIFY_CLIENT') or
375+
os.environ.get('CHELON_VERIFY_CLIENT', 'false'))
376+
verify_client = str(verify_client_val).lower() == 'true'
370377

371378
ssl_context = None
372379
if ssl_cert and ssl_key:
-10 KB
Binary file not shown.

0 commit comments

Comments
 (0)