getSecretKey(), true); return base64_encode($version . $signature); } /** * Create an SMTP password for a given IAM user's credentials. * * The SMTP username is the Access Key ID for the provided credentials. This * utility method is not guaranteed to work indefinitely and is provided as * a convenience to customers using the generateSmtpPassword method. It is * not recommended for use in production * * @link https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-convert * * @param CredentialsInterface $creds * @param string $region * * @return string */ public static function generateSmtpPasswordV4(CredentialsInterface $creds, $region) { $key = $creds->getSecretKey(); $date = "11111111"; $service = "ses"; $terminal = "aws4_request"; $message = "SendRawEmail"; $version = 0x04; $signature = self::sign($date, "AWS4" . $key); $signature = self::sign($region, $signature); $signature = self::sign($service, $signature); $signature = self::sign($terminal, $signature); $signature = self::sign($message, $signature); $signatureAndVersion = pack('c', $version) . $signature; return base64_encode($signatureAndVersion); } private static function sign($key, $message) { return hash_hmac('sha256', $key, $message, true); } /** * @internal * @codeCoverageIgnore */ public static function applyDocFilters(array $api, array $docs) { $b64 = '
This value will be base64 encoded on your behalf.
'; $docs['shapes']['RawMessage']['append'] = $b64; return [ new Service($api, ApiProvider::defaultProvider()), new DocModel($docs) ]; } }