-
-
Save pulsation/e02307d2f4d229cc3522 to your computer and use it in GitHub Desktop.
Test WSSE token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
function wsse_header($username, $password) { | |
$nonce = hash_hmac('sha512', uniqid(null, true), uniqid(), true); | |
$created = new DateTime('now', new DateTimezone('UTC')); | |
$created = $created->format(DateTime::ISO8601); | |
$digest = sha1($nonce.$created.$password, true); | |
return sprintf( | |
'X-WSSE: UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"', | |
$username, | |
base64_encode($digest), | |
base64_encode($nonce), | |
$created | |
); | |
} | |
if (4 === $argc) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $argv[3]); | |
curl_setopt($ch, CURLOPT_VERBOSE, 1); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array(wsse_header($argv[1], $argv[2]))); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
$data = curl_exec($ch); | |
curl_close($ch); | |
echo "\n"; | |
exit(0); | |
} else { | |
printf("Usage: %s [username] [password] [url]\n", ltrim($argv[0], './')); | |
exit(1); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment