SlideShare a Scribd company logo
Copyright © 2018 HashiCorp
Vault API for the REST
of us
How to access Vault whether you’re in a full stateful environment
or a minimalist McGuyver sidecar.
Version: 1119.18
Copyright © 2018 HashiCorp ⁄
REST API: Options
2
Copyright © 2018 HashiCorp ⁄
1: CLI
2: HTTP
3: HTTPS
4: Binding
5: Other client
3
Copyright © 2018 HashiCorp ⁄
CLI
Copyright © 2018 HashiCorp ⁄⁄ 4
Simplicity:
Vault binary actually covers Server, Agent, CLI.
Pros:
Simplicity. Single binary does all.
Parameter -output-curl-url can generate our REST call for learning curve.
Help menu provided.
Cons:
Bulk: 127MB binary (Golang, no dependencies)
Often too large for a sidecar or container environment.
Golang CA chain caveats.
Not always an option.
Copyright © 2018 HashiCorp ⁄
CLI to API
5
#!/bin/bash
# Example vault override to convert script to curl commands.
# Use this function to override vault for curl
function vault {
arg1=$1
shift
/usr/local/bin/vault $arg1 -output-curl-string $@
}
vault write auth/jwt/login role=test jwt=MYJWT
vault write pki/issue/example common_name=test.com
vault read kv/test
$ batch.sh
curl -X PUT -H "X-Vault-Token: $(vault print token)" -d '{"jwt":"MYJWT","role":"test"}'  http://
127.0.0.1:8200/v1/auth/jwt/login
curl -X PUT -H "X-Vault-Token: $(vault print token)" -d '{"common_name":"test.com"}'  http://127.0.0.1:8200/
v1/pki/issue/example
curl -H "X-Vault-Token: $(vault print token)" http://127.0.0.1:8200/v1/kv/test
Copyright © 2018 HashiCorp ⁄
HTTP
or
HTTPS
Copyright © 2018 HashiCorp ⁄⁄ 6
Simplicity:
Low overhead. Flexible
Pros:
Simplicity. Accessible with standard libs.
Security via HTTPS
Lightweight HTTP: access via Curl or /dev/tcp (bash only)
Lightweight HTTPS: access via Curl or just OpenSSL client.
Suitable for automation or wrappers.
Cons:
Great developer experience. Less easy as a user experience.
Copyright © 2018 HashiCorp ⁄
HTTP (raw /dev/tcp)
7
#!/bin/bash
# Access raw Vault API without curl, wget, or vault binary.
function vaultRaw
{
exec 3<>/dev/tcp/localhost/8200
cat <<EOF >&3
GET /$1 HTTP/1.1
Host: localhost:8200
X-Vault-Token: $VAULT_TOKEN
Connection: close
EOF
cat <&3
}
# Fetch health
vaultRaw v1/sys/health
# Fetch seal-status
vaultRaw v1/sys/seal-status
Copyright © 2018 HashiCorp ⁄
HTTP (raw /dev/tcp) output
8
$ ./vault-raw-api.sh
HTTP/1.1 200 OK
Cache-Control: no-store
Content-Type: application/json
Date: Tue, 05 Nov 2019 01:40:36 GMT
Content-Length: 298
Connection: close
{"initialized":true,"sealed":false,"standby":false,"performance_standby":false,"replication_performance_mode":"
disabled","replication_dr_mode":"disabled","server_time_utc":
1572918036,"version":"1.2.3+ent","cluster_name":"vault-cluster-e97e0603","cluster_id":"4da14b8c-b2fd-56e1-a104-
bbf1eac855f5"}
HTTP/1.1 200 OK
Cache-Control: no-store
Content-Type: application/json
Date: Tue, 05 Nov 2019 01:40:36 GMT
Content-Length: 242
Connection: close
{"type":"shamir","initialized":true,"sealed":false,"t":1,"n":1,"progress":
0,"nonce":"","version":"1.2.3+ent","migration":false,"cluster_name":"vault-cluster-
e97e0603","cluster_id":"4da14b8c-b2fd-56e1-a104-bbf1eac855f5","recovery_seal":false}
Copyright © 2018 HashiCorp ⁄
HTTPS (openssl s client)
9
#!/bin/bash -x
# John Boero - a script to access Vault using only OpenSSL Client
# ARG1 is your endpoint requested (GET by default)
openssl s_client -quiet -connect localhost:8200 <<EOF
GET /$1 HTTP/1.1
Host: localhost:8200
X-Vault-Token: $VAULT_TOKEN
Connection: close
EOF
Copyright © 2018 HashiCorp ⁄
HTTPS (openssl) output
10
$ ./vault-tls-example.sh v1/sys/health
+ openssl s_client -quiet -connect localhost:8200
Can't use SSL_get_servername
depth=0 C = UK, L = London, O = Default Company Ltd, CN = localhost
verify return:1
depth=0 C = UK, L = London, O = Default Company Ltd, CN = localhost
verify return:1
HTTP/1.1 200 OK
Cache-Control: no-store
Content-Type: application/json
Date: Tue, 05 Nov 2019 02:01:06 GMT
Content-Length: 298
Connection: close
{"initialized":true,"sealed":false,"standby":false,"performance_standby":false,"replication_performance_mode":"
disabled","replication_dr_mode":"disabled","server_time_utc":
1572919266,"version":"1.2.3+ent","cluster_name":"vault-cluster-e97e0603","cluster_id":"4da14b8c-b2fd-56e1-a104-
bbf1eac855f5"}
Copyright © 2018 HashiCorp ⁄
Bindings
Copyright © 2018 HashiCorp ⁄⁄ 11
Simplicity:
Native library wrappers for the languages you prefer.
Community and supported libraries here:
https://www.vaultproject.io/api/libraries.html
Pros:
Simplicity. Accessible with standard libs.
Suitable for automation or wrappers.
Simple learning curve.
Cons:
Library maintainers must keep up with server releases.
www.hashicorp.com
hello@hashicorp.com
Thank you

More Related Content

PPTX
Delivering Secret Zero: Vault AppRole with Terraform and Chef
PPTX
Vault Agent and Vault 0.11 features
PDF
Vault 1.0: How to Auto-Unseal and Other New Features
PDF
Consul 1.6: Layer 7 Traffic Management and Mesh Gateways
PDF
Keybase Vault Auto-Unseal HashiTalks2020
PDF
Java Microservices with Netflix OSS & Spring
PDF
Secure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CI
PPTX
Nginx Deep Dive Kubernetes Ingress
Delivering Secret Zero: Vault AppRole with Terraform and Chef
Vault Agent and Vault 0.11 features
Vault 1.0: How to Auto-Unseal and Other New Features
Consul 1.6: Layer 7 Traffic Management and Mesh Gateways
Keybase Vault Auto-Unseal HashiTalks2020
Java Microservices with Netflix OSS & Spring
Secure Infrastructure Provisioning with Terraform Cloud, Vault + GitLab CI
Nginx Deep Dive Kubernetes Ingress

What's hot (20)

PPTX
Securing AWS Accounts with Hashi Vault
PDF
Deploying NGINX Plus with Ansible
PPTX
Rein in Your Cloud Costs with Terraform and AWS Lambda
PPTX
The Challenges of Becoming Cloud Native
PDF
AWS re:Invent re:Cap 2019: My ElasticSearch Journey on AWS
PPTX
Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...
PDF
Terraform 0.12 Deep Dive: HCL 2.0 for Infrastructure as Code, Remote Plan & A...
PDF
CDK Meetup: Rule the World through IaC
PDF
Kubernetes scheduling and QoS
PDF
Developing a user-friendly OpenResty application
PDF
Defining & Enforcing Policies the GitOps Way
PDF
NGINX Ingress Controller for Kubernetes
PDF
Microservices with Netflix OSS and Spring Cloud - Dev Day Orange
PDF
DockerCon Live 2020 - Securing Your Containerized Application with NGINX
PDF
Kubernetes 101 and Fun
PDF
Commodified IaC using Terraform Cloud
PDF
NGINX: Basics and Best Practices EMEA
PPTX
Ingress overview
PPTX
NGINX Plus R20 Webinar EMEA
PDF
What’s New in NGINX Plus R16? – EMEA
Securing AWS Accounts with Hashi Vault
Deploying NGINX Plus with Ansible
Rein in Your Cloud Costs with Terraform and AWS Lambda
The Challenges of Becoming Cloud Native
AWS re:Invent re:Cap 2019: My ElasticSearch Journey on AWS
Secure and Convenient Workflows: Integrating HashiCorp Vault with Pivotal Clo...
Terraform 0.12 Deep Dive: HCL 2.0 for Infrastructure as Code, Remote Plan & A...
CDK Meetup: Rule the World through IaC
Kubernetes scheduling and QoS
Developing a user-friendly OpenResty application
Defining & Enforcing Policies the GitOps Way
NGINX Ingress Controller for Kubernetes
Microservices with Netflix OSS and Spring Cloud - Dev Day Orange
DockerCon Live 2020 - Securing Your Containerized Application with NGINX
Kubernetes 101 and Fun
Commodified IaC using Terraform Cloud
NGINX: Basics and Best Practices EMEA
Ingress overview
NGINX Plus R20 Webinar EMEA
What’s New in NGINX Plus R16? – EMEA
Ad

Similar to Vault Secrets Via API for the REST of Us (20)

PDF
Caching the Uncacheable
PDF
Apache and PHP: Why httpd.conf is your new BFF!
PDF
Php through the eyes of a hoster confoo
KEY
Plack at YAPC::NA 2010
PDF
Php through the eyes of a hoster phpbnl11
PDF
HTTP Caching and PHP
PDF
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
PDF
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
KEY
Plack perl superglue for web frameworks and servers
DOCX
Php version 5
PDF
Fargate 를 이용한 ECS with VPC 1부
PDF
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
PDF
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - HMAC and http...
PDF
Ports, pods and proxies
PDF
Год в Github bugbounty, опыт участия
PDF
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
PDF
ApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
KEY
PSGI/Plack OSDC.TW
PDF
Securing REST APIs
PDF
Kubernetes security
Caching the Uncacheable
Apache and PHP: Why httpd.conf is your new BFF!
Php through the eyes of a hoster confoo
Plack at YAPC::NA 2010
Php through the eyes of a hoster phpbnl11
HTTP Caching and PHP
Leverage HTTP to deliver cacheable websites - Codemotion Rome 2018
Leverage HTTP to deliver cacheable websites - Thijs Feryn - Codemotion Rome 2018
Plack perl superglue for web frameworks and servers
Php version 5
Fargate 를 이용한 ECS with VPC 1부
Chickens & Eggs: Managing secrets in AWS with Hashicorp Vault
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - HMAC and http...
Ports, pods and proxies
Год в Github bugbounty, опыт участия
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
ApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
PSGI/Plack OSDC.TW
Securing REST APIs
Kubernetes security
Ad

More from Mitchell Pronschinske (20)

PDF
Getting Started with Kubernetes and Consul
PDF
Multi-Cloud with Nomad and Consul Connect
PDF
Code quality for Terraform
PDF
Dynamic Azure Credentials for Applications and CI/CD Pipelines
PPTX
Migrating from VMs to Kubernetes using HashiCorp Consul Service on Azure
PPTX
Empowering developers and operators through Gitlab and HashiCorp
PPTX
Automate and simplify multi cloud complexity with f5 and hashi corp
PDF
Vault 1.5 Overview
PPTX
Using new sentinel features in terraform cloud
PDF
Military Edge Computing with Vault and Consul
PDF
Unlocking the Cloud operating model with GitHub Actions
PDF
Vault 1.4 integrated storage overview
PDF
Unlocking the Cloud Operating Model
PPTX
Cisco ACI with HashiCorp Terraform (APAC)
PPTX
Governance for Multiple Teams Sharing a Nomad Cluster
PDF
Integrating Terraform and Consul
PPTX
Unlocking the Cloud Operating Model: Deployment
PPTX
Keeping a Secret with HashiCorp Vault
PPTX
Modern Scheduling for Modern Applications with Nomad
PPTX
Moving to a Microservice World: Leveraging Consul on Azure
Getting Started with Kubernetes and Consul
Multi-Cloud with Nomad and Consul Connect
Code quality for Terraform
Dynamic Azure Credentials for Applications and CI/CD Pipelines
Migrating from VMs to Kubernetes using HashiCorp Consul Service on Azure
Empowering developers and operators through Gitlab and HashiCorp
Automate and simplify multi cloud complexity with f5 and hashi corp
Vault 1.5 Overview
Using new sentinel features in terraform cloud
Military Edge Computing with Vault and Consul
Unlocking the Cloud operating model with GitHub Actions
Vault 1.4 integrated storage overview
Unlocking the Cloud Operating Model
Cisco ACI with HashiCorp Terraform (APAC)
Governance for Multiple Teams Sharing a Nomad Cluster
Integrating Terraform and Consul
Unlocking the Cloud Operating Model: Deployment
Keeping a Secret with HashiCorp Vault
Modern Scheduling for Modern Applications with Nomad
Moving to a Microservice World: Leveraging Consul on Azure

Recently uploaded (20)

PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
System and Network Administration Chapter 2
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Digital Strategies for Manufacturing Companies
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
System and Network Administraation Chapter 3
PDF
medical staffing services at VALiNTRY
Upgrade and Innovation Strategies for SAP ERP Customers
How to Choose the Right IT Partner for Your Business in Malaysia
Reimagine Home Health with the Power of Agentic AI​
System and Network Administration Chapter 2
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Softaken Excel to vCard Converter Software.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
VVF-Customer-Presentation2025-Ver1.9.pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Digital Strategies for Manufacturing Companies
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Understanding Forklifts - TECH EHS Solution
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
System and Network Administraation Chapter 3
medical staffing services at VALiNTRY

Vault Secrets Via API for the REST of Us

  • 1. Copyright © 2018 HashiCorp Vault API for the REST of us How to access Vault whether you’re in a full stateful environment or a minimalist McGuyver sidecar. Version: 1119.18
  • 2. Copyright © 2018 HashiCorp ⁄ REST API: Options 2
  • 3. Copyright © 2018 HashiCorp ⁄ 1: CLI 2: HTTP 3: HTTPS 4: Binding 5: Other client 3
  • 4. Copyright © 2018 HashiCorp ⁄ CLI Copyright © 2018 HashiCorp ⁄⁄ 4 Simplicity: Vault binary actually covers Server, Agent, CLI. Pros: Simplicity. Single binary does all. Parameter -output-curl-url can generate our REST call for learning curve. Help menu provided. Cons: Bulk: 127MB binary (Golang, no dependencies) Often too large for a sidecar or container environment. Golang CA chain caveats. Not always an option.
  • 5. Copyright © 2018 HashiCorp ⁄ CLI to API 5 #!/bin/bash # Example vault override to convert script to curl commands. # Use this function to override vault for curl function vault { arg1=$1 shift /usr/local/bin/vault $arg1 -output-curl-string $@ } vault write auth/jwt/login role=test jwt=MYJWT vault write pki/issue/example common_name=test.com vault read kv/test $ batch.sh curl -X PUT -H "X-Vault-Token: $(vault print token)" -d '{"jwt":"MYJWT","role":"test"}' http:// 127.0.0.1:8200/v1/auth/jwt/login curl -X PUT -H "X-Vault-Token: $(vault print token)" -d '{"common_name":"test.com"}' http://127.0.0.1:8200/ v1/pki/issue/example curl -H "X-Vault-Token: $(vault print token)" http://127.0.0.1:8200/v1/kv/test
  • 6. Copyright © 2018 HashiCorp ⁄ HTTP or HTTPS Copyright © 2018 HashiCorp ⁄⁄ 6 Simplicity: Low overhead. Flexible Pros: Simplicity. Accessible with standard libs. Security via HTTPS Lightweight HTTP: access via Curl or /dev/tcp (bash only) Lightweight HTTPS: access via Curl or just OpenSSL client. Suitable for automation or wrappers. Cons: Great developer experience. Less easy as a user experience.
  • 7. Copyright © 2018 HashiCorp ⁄ HTTP (raw /dev/tcp) 7 #!/bin/bash # Access raw Vault API without curl, wget, or vault binary. function vaultRaw { exec 3<>/dev/tcp/localhost/8200 cat <<EOF >&3 GET /$1 HTTP/1.1 Host: localhost:8200 X-Vault-Token: $VAULT_TOKEN Connection: close EOF cat <&3 } # Fetch health vaultRaw v1/sys/health # Fetch seal-status vaultRaw v1/sys/seal-status
  • 8. Copyright © 2018 HashiCorp ⁄ HTTP (raw /dev/tcp) output 8 $ ./vault-raw-api.sh HTTP/1.1 200 OK Cache-Control: no-store Content-Type: application/json Date: Tue, 05 Nov 2019 01:40:36 GMT Content-Length: 298 Connection: close {"initialized":true,"sealed":false,"standby":false,"performance_standby":false,"replication_performance_mode":" disabled","replication_dr_mode":"disabled","server_time_utc": 1572918036,"version":"1.2.3+ent","cluster_name":"vault-cluster-e97e0603","cluster_id":"4da14b8c-b2fd-56e1-a104- bbf1eac855f5"} HTTP/1.1 200 OK Cache-Control: no-store Content-Type: application/json Date: Tue, 05 Nov 2019 01:40:36 GMT Content-Length: 242 Connection: close {"type":"shamir","initialized":true,"sealed":false,"t":1,"n":1,"progress": 0,"nonce":"","version":"1.2.3+ent","migration":false,"cluster_name":"vault-cluster- e97e0603","cluster_id":"4da14b8c-b2fd-56e1-a104-bbf1eac855f5","recovery_seal":false}
  • 9. Copyright © 2018 HashiCorp ⁄ HTTPS (openssl s client) 9 #!/bin/bash -x # John Boero - a script to access Vault using only OpenSSL Client # ARG1 is your endpoint requested (GET by default) openssl s_client -quiet -connect localhost:8200 <<EOF GET /$1 HTTP/1.1 Host: localhost:8200 X-Vault-Token: $VAULT_TOKEN Connection: close EOF
  • 10. Copyright © 2018 HashiCorp ⁄ HTTPS (openssl) output 10 $ ./vault-tls-example.sh v1/sys/health + openssl s_client -quiet -connect localhost:8200 Can't use SSL_get_servername depth=0 C = UK, L = London, O = Default Company Ltd, CN = localhost verify return:1 depth=0 C = UK, L = London, O = Default Company Ltd, CN = localhost verify return:1 HTTP/1.1 200 OK Cache-Control: no-store Content-Type: application/json Date: Tue, 05 Nov 2019 02:01:06 GMT Content-Length: 298 Connection: close {"initialized":true,"sealed":false,"standby":false,"performance_standby":false,"replication_performance_mode":" disabled","replication_dr_mode":"disabled","server_time_utc": 1572919266,"version":"1.2.3+ent","cluster_name":"vault-cluster-e97e0603","cluster_id":"4da14b8c-b2fd-56e1-a104- bbf1eac855f5"}
  • 11. Copyright © 2018 HashiCorp ⁄ Bindings Copyright © 2018 HashiCorp ⁄⁄ 11 Simplicity: Native library wrappers for the languages you prefer. Community and supported libraries here: https://www.vaultproject.io/api/libraries.html Pros: Simplicity. Accessible with standard libs. Suitable for automation or wrappers. Simple learning curve. Cons: Library maintainers must keep up with server releases.