SDK for PHP 3.x

MessageValidator
in package

Uses openssl to verify SNS messages to ensure that they were sent by AWS.

Table of Contents

Constants

SIGNATURE_VERSION_1  = '1'
SIGNATURE_VERSION_2  = '2'

Methods

__construct()  : mixed
Constructs the Message Validator object and ensures that openssl is installed.
getStringToSign()  : string
Builds string-to-sign according to the SNS message spec.
isValid()  : bool
Determines if a message is valid and that is was delivered by AWS. This method does not throw exceptions and returns a simple boolean value.
validate()  : mixed
Validates a message from SNS to ensure that it was delivered by AWS.

Constants

SIGNATURE_VERSION_1

public mixed SIGNATURE_VERSION_1 = '1'

SIGNATURE_VERSION_2

public mixed SIGNATURE_VERSION_2 = '2'

Methods

__construct()

Constructs the Message Validator object and ensures that openssl is installed.

public __construct([callable $certClient = null ][, string $hostNamePattern = '' ]) : mixed
Parameters
$certClient : callable = null

Callable used to download the certificate. Should have the following function signature: function (string $certUrl) : string|false $certContent

$hostNamePattern : string = ''

isValid()

Determines if a message is valid and that is was delivered by AWS. This method does not throw exceptions and returns a simple boolean value.

public isValid(Message $message) : bool
Parameters
$message : Message

The message to validate

Return values
bool

validate()

Validates a message from SNS to ensure that it was delivered by AWS.

public validate(Message $message) : mixed
Parameters
$message : Message

Message to validate.

Tags
throws
InvalidSnsMessageException

If the cert cannot be retrieved or its source verified, or the message signature is invalid.

On this page