Skip to content

Commit

Permalink
Merge pull request OpenSIPS#3444 from Integration-IT/master
Browse files Browse the repository at this point in the history
Update stir_shaken.c - enforce stir_shaken_verify pvar generic error reason
  • Loading branch information
liviuchircu authored Aug 20, 2024
2 parents b36a247 + 2f5be16 commit a2c0054
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 6 additions & 6 deletions modules/stir_shaken/stir_shaken.c
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
if ((rc = get_parsed_identity( msg, &parsed)) < 0) {
if (rc == -1) {
LM_ERR("Failed to parse identity header\n");
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_PARSE_IDENTITY);
} else { /* rc == -4 */
LM_INFO("Invalid identity header\n");
SET_VERIFY_ERR_VARS(INVALID_IDENTITY_CODE, INVALID_IDENTITY_REASON);
Expand Down Expand Up @@ -2028,7 +2028,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,

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

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

if (load_cert(&cert, &certchain, cert_buf) < 0) {
LM_ERR("Failed to load certificate\n");
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_LOAD_CERTIFICATE);
rc = -1;
goto error;
}
Expand All @@ -2119,7 +2119,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
if ((rc = validate_certificate(cert, certchain)) < 0) {
if (rc == -1) {
LM_ERR("Error validating certificate\n");
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_VALIDATE_CERTIFICATE);
goto error;
} else { /* rc == -8 */
LM_INFO("Invalid certificate\n");
Expand All @@ -2135,7 +2135,7 @@ static int w_stir_verify(struct sip_msg *msg, str *cert_buf,
if ((rc = verify_signature(cert, parsed, iat_ts, orig_tn_p, dest_tn_p)) <= 0) {
if (rc < 0) {
LM_ERR("Error while verifying signature\n");
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON);
SET_VERIFY_ERR_VARS(IERROR_CODE, IERROR_REASON_VERIFY_SIGNATURE);
rc = -1;
goto error;
} else {
Expand Down
7 changes: 7 additions & 0 deletions modules/stir_shaken/stir_shaken.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@
#define INVALID_IDENTITY_REASON "Invalid Identity Header"
#define IERROR_CODE 500
#define IERROR_REASON "Internal Server Error"
#define IERROR_REASON_PARSE_HEADERS "Failed to parse headers"
#define IERROR_REASON_PARSE_IDENTITY "Failed to parse identity header"
#define IERROR_REASON_GET_CURRENT_TIME "Failed to get current time"
#define IERROR_REASON_GET_TIME_FROM_DATE_HEADER "Failed to get UNIX time from Date header"
#define IERROR_REASON_LOAD_CERTIFICATE "Failed to load certificate"
#define IERROR_REASON_VALIDATE_CERTIFICATE "Error validating certificate"
#define IERROR_REASON_VERIFY_SIGNATURE "Error while verifying signature"

#define TN_AUTH_LIST_OID "1.3.6.1.5.5.7.1.26"
#define TN_AUTH_LIST_LN "TNAuthorizationList"
Expand Down

0 comments on commit a2c0054

Please sign in to comment.