Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating new cache doesn't return error even if storage key is wrong #1

Closed
renxinhe opened this issue Jun 3, 2022 · 3 comments
Closed

Comments

@renxinhe
Copy link
Contributor

renxinhe commented Jun 3, 2022

I tried testing Azure storage authentication using the following code:

autocertCacheAzureStorageAccountKey = "YmFkY3JlZGVudGlhbA==" // base64 encoded string "badcredential"

azureCertCache, err := azcertcache.New(
        autocertCacheAzureStorageAccountName,
	autocertCacheAzureStorageAccountKey,
	autocertCacheAzureStorageContainerName,
)

I encoded a purposely wrong account key in base64 and passed it into autocertCacheAzureStorageAccountKey. This should have returned an authentication error, however, err is returned as nil.

During runtime, when the server receives its first HTTPS request, it would fail to obtain the certificate from the Blob Storage.

https server started on [::]:443
echo: http: TLS handshake error from <REDACTED>:56440: -> github.com/Azure/azure-storage-blob-go/azblob.NewResponseError, /home/os/go/pkg/mod/github.com/!azure/azure-storage-blob-go@v0.0.0-20190123011202-457680cc0804/azblob/zz_generated_response_error.go:29
===== RESPONSE ERROR (ServiceCode=AuthenticationFailed) =====
Description=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:<REDACTED>
Time:2022-06-01T19:27:41.4488737Z, Details:
   AuthenticationErrorDetail: The MAC signature found in the HTTP request 'GVFuzxZ2UEFZSGUQt8HUt+0iNHDN6K007YKFKcZkbWc=' is not the same as any computed signature. Server used following string to sign: 'GET
x-ms-client-request-id:42dbaddb-0344-4092-5034-06bc350961d7
x-ms-date:Wed, 01 Jun 2022 19:27:41 GMT
x-ms-version:2018-03-28
/<REDACTED_azure_storage_name>/<REDACTED_container_name>/<REDACTED_dns_cname>
timeout:61'.
   Code: AuthenticationFailed
   GET https://<REDACTED_azure_storage_name>.blob.core.windows.net/<REDACTED_container_name>/<REDACTED_dns_cname>?timeout=61
   Authorization: REDACTED
   User-Agent: [Azure-Storage/0.5 (go1.17.4; linux)]
   X-Ms-Client-Request-Id: [42dbaddb-0344-4092-5034-06bc350961d7]
   X-Ms-Date: [Wed, 01 Jun 2022 19:27:41 GMT]
   X-Ms-Version: [2018-03-28]
   --------------------------------------------------------------------------------
   RESPONSE Status: 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
   Content-Length: [783]
   Content-Type: [application/xml]
   Date: [Wed, 01 Jun 2022 19:27:40 GMT]
   Server: [Microsoft-HTTPAPI/2.0]
   X-Ms-Error-Code: [AuthenticationFailed]
   X-Ms-Request-Id: [93dbd2ed-101e-0036-3aed-75ec6e000000]

I think azcertcache.New should return an error if the storage credential is wrong, instead of failing when the first HTTPS request comes in.

@goenning
Copy link
Owner

goenning commented Jun 4, 2022

I’m no longer using this package, but you send a PR I can merge it 👍

@renxinhe
Copy link
Contributor Author

renxinhe commented Jun 7, 2022

@goenning I submitted a PR. Please take a look when you have time. Thanks!

@goenning
Copy link
Owner

goenning commented Jun 7, 2022

Thank you!

@goenning goenning closed this as completed Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants