public static CrtResult <String> SignCanonicalRequest(String canonicalRequest, AwsSigningConfig signingConfig) { if (canonicalRequest == null || signingConfig == null) { throw new CrtException("Null argument passed to SignRequest"); } if (signingConfig.SignatureType != AwsSignatureType.CANONICAL_REQUEST_VIA_HEADERS && signingConfig.SignatureType != AwsSignatureType.CANONICAL_REQUEST_VIA_QUERY_PARAMS) { throw new CrtException("Illegal signing type for canonical request signing"); } var nativeConfig = new AwsSigningConfigNative(signingConfig); CanonicalRequestSigningCallback callback = new CanonicalRequestSigningCallback(); callback.OriginalCanonicalRequest = canonicalRequest; ulong id = PendingCanonicalRequestSignings.AcquireStrongReference(callback); API.SignCanonicalRequestNative(canonicalRequest, nativeConfig, id, API.OnCanonicalRequestSigningComplete); return(callback.Result); }
private static void OnCanonicalRequestSigningComplete(ulong id, int errorCode, string authorizationValue) { CanonicalRequestSigningCallback callback = PendingCanonicalRequestSignings.ReleaseStrongReference(id); if (callback == null) { return; } if (errorCode != 0) { callback.Result.CompleteExceptionally(new CrtException(errorCode)); } else { callback.Result.Complete(authorizationValue); } }