Skip to content

Commit 07bdfa1

Browse files
fix(CertificateAuthority): set a 409 instead of 403 for bad ca deletions
A conflict error is a more accurate choice when someone tries to delete a CA that is currently in use.
1 parent 8fa83dc commit 07bdfa1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Models/CertificateAuthority.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use RESTAPI\Fields\BooleanField;
88
use RESTAPI\Fields\IntegerField;
99
use RESTAPI\Fields\StringField;
1010
use RESTAPI\Fields\UIDField;
11+
use RESTAPI\Responses\ConflictError;
1112
use RESTAPI\Responses\ForbiddenError;
1213
use RESTAPI\Responses\ValidationError;
1314
use RESTAPI\Validators\RegexValidator;
@@ -116,7 +117,7 @@ class CertificateAuthority extends Model {
116117
public function _delete(): void {
117118
# Do not allow this CertificateAuthority to be deleted if it is in use
118119
if (ca_in_use($this->refid->value)) {
119-
throw new ForbiddenError(
120+
throw new ConflictError(
120121
message: 'Certificate authority cannot be deleted because it is in use.',
121122
response_id: 'CERTIFICATE_AUTHORITY_CANNOT_BE_DELETED_WHILE_IN_USE',
122123
);

0 commit comments

Comments
 (0)