GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Possible Gcloud Java bug in signurl? · Issue #739 · googleapis/google-cloud-java

Possible Gcloud Java bug in signurl? #739

New issue
Copy link
New issue
Copy link
Closed
Closed
Possible Gcloud Java bug in signurl?#739
Copy link
Assignees
mziccard
Labels
api: storageIssues related to the Cloud Storage API.auth

Description

@OverclockedTim
OverclockedTim
opened on Mar 10, 2016
Issue body actions

So I'm using gcloud storage in a managed VM app and generally loving it, but I've hit something that I really think it is a bug so I wanted to throw it out there and see what people think.

I'm doing a few things with Storage and most of them are working perfectly Reads work perfectly, writes work perfectly, creates work perfectly. However, when I attempt to sign a URL like so:

Storage storage = StorageOptions.defaultInstance().service();

URL url = storage.signUrl(
BlobInfo.builder(BUCKET_NAME,
OBJECT_NAME).build(),
30,
TimeUnit.MINUTES,
Storage.SignUrlOption.httpMethod(HttpMethod.GET));

I end up getting a "Signing key not provided" exception:

java.lang.IllegalArgumentException: Signing key was not provided and could not be derived
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
at com.google.gcloud.storage.StorageImpl.signUrl(StorageImpl.java:531)
...

This occurs on a deployed Managed VM server. It also occurs locally when gcloud is authorized either to myself or to a service account. In other words, it appears that storage.signUrl is not picking up signing authorization from the standard locations. I have not yet tried to manually add a signing option from a generated key, but that seems like it should not required. Additionally, the signUrl example from the gcloud-java source in maven has no additional signingKey in the SignUrlOptions which leads me to believe that it is intended for signUrl to pick up its authorization from the environment.

Activity

Next
  1. mziccard commented on Mar 10, 2016

    @mziccard
    mziccard
    on Mar 10, 2016
    Contributor
    More actions

    Hi @OverclockedTim thanks for the report and the kind words:)

    What signUrl does is looking in the credentials you provided to StorageOptions for a private key. If you are authenticated with default credentials you provided no private key (because you don't need to) hence the complaint Signing key not provided.

    To use signUrl when authenticated with default credentials you can pass a private key using the SignUrlOption.serviceAccount option. Your code would become:

    // Create ServiceAccountAuthCredentials from a stream
    ServiceAccountAuthCredentials credentials =
        AuthCredentials.createForJson(new FileInputStream("/path/to/key.json"));
    // or from a String (account) and PrivateKey
    ServiceAccountAuthCredentials credentials =
        AuthCredentials.createFor(ACCOUNT, PRIVATE_KEY);
    // Create the signed URL
    URL url = storage.signUrl(BlobInfo.builder(BUCKET_NAME, OBJECT_NAME).build(), 30,
        TimeUnit.MINUTES, Storage.SignUrlOption.httpMethod(HttpMethod.GET),
        Storage.SignUrlOption.serviceAccount(credentials));

    Let us know if this helps!

    PS: to understand how authentication (and default credentials) work you can have a look at the authentication section in our README.

    Reacted by Kenny
    Reacted by Teju Nareddy
  2. OverclockedTim commented on Mar 10, 2016

    @OverclockedTim
    OverclockedTim
    on Mar 10, 2016
    Author
    More actions

    Hi @mziccard - Thank you! The method you mentioned does in fact work, but that does leave me with some questions: If a private key is always required for this function to succeed, why is it not required in the function signature? (it is optional)

    Also, if a private key is always required, is the example in the comment for signURL (https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java#L1478-L1498) simply always guaranteed to throw the Signing key not provided exception?

    Finally, does this mean that any application that uses signUrl must keep a copy of the JSON key around? This is something that I was hoping to avoid due to the difficulty of keeping that key secure. I would prefer to let Google's internal security handle it if that were possible.

  3. mziccard commented on Mar 10, 2016

    @mziccard
    mziccard
    on Mar 10, 2016
    Contributor
    More actions

    Thank you! The method you mentioned does in fact work, but that does leave me with some questions: If a private key is always required for this function to succeed, why is it not required in the function signature? (it is optional)

    If you set the GOOGLE_DEFAULT_CREDENTIALS variable to point to a JSON key then default credentials you are using detect and use that JSON key to authenticate. In that case providing a key to signUrl is not required, it will detect the one used to authenticate requests and use it. Alternatively you could have created your StorageOptions by providing some ServiceAccountAuthCredentials:

    StorageOptions options = StorageOptions.builder()
        .authCredentials(AuthCredentials.createForJson(new FileInputStream("/path/to/key.json")))
        .build();

    Also in this case passing a key to signUrl is not required, as the one already provided to StorageOptions is used.

    Finally, does this mean that any application that uses signUrl must keep a copy of the JSON key around?

    Signing a URL involves signing with a private key. If the credentials used to authenticate do not expose one (this is the case for App Engine credentials, Compute Engine credentials and Google Cloud SDK credentials) there is nothing we can do to help.

  4. aozarov commented on Mar 10, 2016

    @aozarov
    aozarov
    on Mar 10, 2016
    Contributor
    More actions

    I think we should make that clear in the Storage.signUrl javadoc (credentials for signing is needed and will try to get it from the environment unless explicitly provided). In both method description and @throws tag.

    Also, FYI #701 plans to make the signing credentials options a bit more flexible and we should be able to support it on AE.

    Reacted by Pierluigi Montagna
  5. aozarov
    added
    auth
    api: storageIssues related to the Cloud Storage API.
    on Mar 10, 2016
  6. mziccard
    self-assigned this
    on Mar 10, 2016
  7. mziccard commented on Mar 10, 2016

    @mziccard
    mziccard
    on Mar 10, 2016
    Contributor
    More actions

    I think we should make that clear in the Storage.signUrl javadoc

    I agree, this is tricky indeed. I'm assigning this to myself and I'll take care of adding a better javadoc. I'll post back here the PR if @OverclockedTim wants to give us some feedback on the readability of the javadoc.

  8. OverclockedTim commented on Mar 10, 2016

    @OverclockedTim
    OverclockedTim
    on Mar 10, 2016
    Author
    More actions

    @mziccard - Certainly, if that is helpful, I would be happy to!

  9. OverclockedTim commented on Mar 10, 2016

    @OverclockedTim
    OverclockedTim
    on Mar 10, 2016
    Author
    More actions

    @aozarov Just as a heads up, the thing that I did not understand after reading the javadocs was that the key required for signUrl was different than the credentials required for things like Upload or Read.

  10. mziccard commented on Mar 15, 2016

    @mziccard
    mziccard
    on Mar 15, 2016
    Contributor
    More actions

    Closed with #743

  11. mziccard
    closed this as completedon Mar 15, 2016
  12. theacodes
    unassigned
    mziccard
    on Sep 28, 2018
  13. JustinBeckwith
    assigned
    mziccard
    on Feb 1, 2021
  14. lov001 commented on Jan 21, 2022

    @lov001
    lov001
    on Jan 21, 2022
    More actions

    Hey @mziccard ,
    I'm also stuck with a similar kind of issue, wherein I'm able to perform upload, download, list and delete a file from GCS but when obtaining signedURL I'm getting the above error message. The point I'm still confused is that using the same below code I'm able to perform all other operations but not table to get signedURL. I'm already authenticated with default credentials and the GOOGLE_DEFAULT_CREDENTIALS env variable is also set.
    `

            Storage storage = StorageOptions.getDefaultInstance().getService();
            BlobId blobId = BlobId.of(bucketName, "objectName, Long.getLong(generationID));
            BlobInfo blobInfo = BlobInfo.newBuilder(blobId).build();
           return storage.signUrl(blobInfo, 5, TimeUnit.MINUTES, Storage.SignUrlOption.httpMethod(HttpMethod.GET)
                Storage.SignUrlOption.withV4Signature());`
    

    Would be great if you can point out what I'm doing wrong here.
    Thanks

  15. 14 remaining items

  16. chingor13
    added 3 commits that reference this issue on Jan 6, 2026

    deps: update dependency com.google.cloud:google-cloud-shared-dependen…

    e603a4b

    chore(main): release 0.122.20 (#740)

    4b397a9

    chore(main): release 0.124.0 (#770)

    b5bf336
  17. chingor13
    added 2 commits that reference this issue on Jan 22, 2026

    feat: add build scripts for native image testing in Java 17 (#1440) (#…

    252a174

    chore(main): release 2.5.0 (#729)

    c04b37e
  18. chingor13
    added a commit that references this issue on Feb 24, 2026

    chore: update java-docfx-doclet version (#739)

    4b8276c
  19. suztomo
    added a commit that references this issue on Mar 11, 2026

    chore: update Java and Python dependencies (googleapis#739)

    4b16061
  20. chingor13
    added a commit that references this issue on Mar 12, 2026

    chore: update java-docfx-doclet version (#739)

    8f2e462
  21. suztomo
    added 2 commits that reference this issue on Mar 23, 2026

    feat: add support for PostgreSQL dialect (googleapis#739)

    c6b2e91

    chore(main): release 2.6.0 (googleapis#753)

    b05b329
  22. suztomo
    added a commit that references this issue on Mar 30, 2026

    chore: update repo-metadata.json client_documentation link (#739)

    c72f695
  23. lqiu96
    added a commit that references this issue on Apr 1, 2026

    chore: update repo-metadata.json client_documentation link (#739)

    425d042
  24. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    chore: remove All rights reserved clause from java.header (#739)

    cb088b8

    chore: remove All rights reserved clause from java.header (#739)

    5575b47
  25. benjaminp
    added a commit that references this issue on Jul 13, 2026

    changes without context (googleapis#739)

    ee48dfd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @mziccard
    mziccard

Labels

api: storageIssues related to the Cloud Storage API.auth

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.