Home > Blockchain >  Any request to vault returns "unsupported operation"
Any request to vault returns "unsupported operation"

Time:01-13

pretty much as the title suggests, any request to the vault returns a { errors: [ '1 error occurred:\n\t* unsupported operation\n\n' ] }. I've checked whether or not it has anything to do with the permissions but changing the X-Vault-Token to something else returns a permission denied. The code used to work but since I migrated from plain js to typescript, it seems to be broken but I can't figure out what it could be that typescript does differently, so I'm inclined to say that it isn't typescript related.

I'm using a simple fetch:

// this url should be valid 
// https://www.vaultproject.io/api/secret/pki#list-certificates
const url = "https://localhost:8200/v1/pki/certs";
const request = await fetch(url, {
    headers: {
        credentials: "include",
        "X-Vault-Token": token,
    },
    agent: tlsAgent,
});

const result = await result.json()
/*
this results in { errors: [ '1 error occurred:\n\t* unsupported operation\n\n' ] }
*/

I've googled the symptoms but I found nothing relevant :(. Since this error was also not mentioned in the documentation of Vault, it is possible that it is not vault related at all but that would be weird considering the permission denied when parameters are changed.

Any hints towards the right direction is much appreciated

CodePudding user response:

Listing the certificates is a LIST operation. Vault requires that you use the right HTTP verb because it uses the verb to evaluate what policy applies to a request. So even if you are using the root token for your test (so that no policy applies to you), you still need to use the right verb.

You can probably make your code work by adding method: 'LIST' in your request, or add the parameter list=true to the URL.

  • Related