Skip to content

Commit a2c0054

Browse files
authored
Merge pull request #3444 from Integration-IT/master
Update stir_shaken.c - enforce stir_shaken_verify pvar generic error reason
2 parents b36a247 + 2f5be16 commit a2c0054

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

modules/stir_shaken/stir_shaken.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
19991999
if ((rc = get_parsed_identity( msg, &parsed)) < 0) {
20002000
if (rc == -1) {
20012001
LM_ERR("Failed to parse identity header\n");
2002-
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
2002+
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_PARSE_IDENTITY);
20032003
} else { /* rc == -4 */
20042004
LM_INFO("Invalid identity header\n");
20052005
SET_VERIFY_ERR_VARS(INVALID_IDENTITY_CODE, INVALID_IDENTITY_REASON);
@@ -2028,7 +2028,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
20282028

20292029
if ((now = time(0)) == -1) {
20302030
LM_ERR("Failed to get current time\n");
2031-
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
2031+
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_GET_CURRENT_TIME);
20322032
rc = -1;
20332033
goto error;
20342034
}
@@ -2045,7 +2045,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
20452045

20462046
if (get_date_ts(date_hf, &date_ts) < 0) {
20472047
LM_ERR("Failed to get UNIX time from Date header\n");
2048-
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
2048+
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_GET_TIME_FROM_DATE_HEADER);
20492049
rc = -1;
20502050
goto error;
20512051
}
@@ -2095,7 +2095,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
20952095

20962096
if (load_cert(&cert, &certchain, cert_buf) < 0) {
20972097
LM_ERR("Failed to load certificate\n");
2098-
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
2098+
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_LOAD_CERTIFICATE);
20992099
rc = -1;
21002100
goto error;
21012101
}
@@ -2119,7 +2119,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
21192119
if ((rc = validate_certificate(cert, certchain)) < 0) {
21202120
if (rc == -1) {
21212121
LM_ERR("Error validating certificate\n");
2122-
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
2122+
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_VALIDATE_CERTIFICATE);
21232123
goto error;
21242124
} else { /* rc == -8 */
21252125
LM_INFO("Invalid certificate\n");
@@ -2135,7 +2135,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
21352135
if ((rc = verify_signature(cert, parsed, iat_ts, orig_tn_p, dest_tn_p)) <= 0) {
21362136
if (rc < 0) {
21372137
LM_ERR("Error while verifying signature\n");
2138-
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
2138+
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_VERIFY_SIGNATURE);
21392139
rc = -1;
21402140
goto error;
21412141
} else {

modules/stir_shaken/stir_shaken.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@
8888
#define INVALID_IDENTITY_REASON "Invalid Identity Header"
8989
#define IERROR_CODE 500
9090
#define IERROR_REASON "Internal Server Error"
91+
#define IERROR_REASON_PARSE_HEADERS "Failed to parse headers"
92+
#define IERROR_REASON_PARSE_IDENTITY "Failed to parse identity header"
93+
#define IERROR_REASON_GET_CURRENT_TIME "Failed to get current time"
94+
#define IERROR_REASON_GET_TIME_FROM_DATE_HEADER "Failed to get UNIX time from Date header"
95+
#define IERROR_REASON_LOAD_CERTIFICATE "Failed to load certificate"
96+
#define IERROR_REASON_VALIDATE_CERTIFICATE "Error validating certificate"
97+
#define IERROR_REASON_VERIFY_SIGNATURE "Error while verifying signature"
9198

9299
#define TN_AUTH_LIST_OID "1.3.6.1.5.5.7.1.26"
93100
#define TN_AUTH_LIST_LN "TNAuthorizationList"

0 commit comments

Comments
 (0)