Skip to content

Commit 777c8d2

Browse files
committed
add new API command: setSslCrt
This replaces updateSslCrt to better align with the HAProxy API command.
1 parent 8b45dc2 commit 777c8d2

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
* New API command: setSslCrt
12+
13+
### Deprecated
14+
* Deprecate API command: updateSslCrt
15+
816
## [v0.6.1] - 2023-12-05
917

1018
### Changed

haproxy/cmds.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,20 @@ class newSslCrt(Cmd):
259259
helpTxt = "Create a new certificate file to be used in a crt-list or a directory."
260260

261261

262-
class updateSslCrt(Cmd):
262+
class setSslCrt(Cmd):
263263
"""" Begin a transaction to upload the certificate into a slot in HAProxy’s memory """
264264
cmdTxt = "set ssl cert %(certfile)s <<\n%(payload)s\r\n"
265265
req_args = ['certfile', 'payload']
266266
helpTxt = "Replace a certificate file."
267267

268268

269+
class updateSslCrt(Cmd):
270+
"""" DEPRECATED. Begin a transaction to upload the certificate into a slot in HAProxy’s memory """
271+
cmdTxt = "set ssl cert %(certfile)s <<\n%(payload)s\r\n"
272+
req_args = ['certfile', 'payload']
273+
helpTxt = "DEPRECATED. Alias for setSslCrt. Kept for compatibility reasons."
274+
275+
269276
class delSslCrt(Cmd):
270277
"""" Begin a transaction to remove the certificate from a slot in HAProxy’s memory """
271278
cmdTxt = "del ssl cert %(certfile)s\r\n"

haproxy/tests/test_cmds.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def setUp(self):
152152
"del-from-crt-list": ("del ssl crt-list /tmp/haproxy/ssl/601a7392cc9984.99301413.certlist"
153153
" /tmp/haproxy/ssl/601a70e4844b0.pem"),
154154
"new-ssl-cert": "new ssl cert /tmp/haproxy/ssl/601a70e4844b0.pem",
155+
"set-ssl-cert": "set ssl cert /tmp/haproxy/ssl/601a70e4844b0.pem <<\n%s" % self.pem_cert_content,
155156
"update-ssl-cert": "set ssl cert /tmp/haproxy/ssl/601a70e4844b0.pem <<\n%s" % self.pem_cert_content,
156157
"del-ssl-cert": "del ssl cert /tmp/haproxy/ssl/601a70e4844b0.pem",
157158
"commit-ssl-cert": "commit ssl cert /tmp/haproxy/ssl/601a70e4844b0.pem",
@@ -258,6 +259,15 @@ def test_newSslCrt(self):
258259
cmdOutput = cmds.newSslCrt(**args).getCmd()
259260
self.assertEqual(cmdOutput, self.Resp["new-ssl-cert"])
260261

262+
def test_setSslCrt(self):
263+
"""Test 'set ssl cert <certfile> <payload>' command"""
264+
args = {
265+
"certfile": "/tmp/haproxy/ssl/601a70e4844b0.pem",
266+
"payload": "%s" % self.pem_cert_content
267+
}
268+
cmdOutput = cmds.setSslCrt(**args).getCmd()
269+
self.assertEqual(cmdOutput, self.Resp["set-ssl-cert"])
270+
261271
def test_updateSslCrt(self):
262272
"""Test 'set ssl cert <certfile> <payload>' command"""
263273
args = {

0 commit comments

Comments
 (0)