github.com/Venafi/vcert/v5@v5.10.2/README.md (about)

     1  [![Venafi](https://raw.githubusercontent.com/Venafi/.github/master/images/Venafi_logo.png)](https://www.venafi.com/)
     2  [![Apache 2.0 License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
     3  ![Community Supported](https://img.shields.io/badge/Support%20Level-Community-brightgreen)
     4  ![Compatible with TPP 17.3+ & VCP & Firefly](https://img.shields.io/badge/Compatibility-TPP%2017.3+%20%26%20VCP%20%26%20Firefly-f9a90c)  
     5  _**This open source project is community-supported.** To report a problem or share an idea, use
     6  **[Issues](../../issues)**; and if you have a suggestion for fixing the issue, please include those details, too.
     7  In addition, use **[Pull Requests](../../pulls)** to contribute actual bug fixes or proposed enhancements.
     8  We welcome and appreciate all contributions. Got questions or want to discuss something with our team?
     9  **[Join us on Slack](https://join.slack.com/t/venafi-integrations/shared_invite/zt-i8fwc379-kDJlmzU8OiIQOJFSwiA~dg)**!_
    10  
    11  # VCert
    12  
    13  [![GoDoc](https://godoc.org/github.com/Venafi/vcert?status.svg)](https://pkg.go.dev/github.com/Venafi/vcert)
    14  [![Go Report Card](https://goreportcard.com/badge/github.com/Venafi/vcert)](https://goreportcard.com/report/github.com/Venafi/vcert)
    15  [![Used By](https://sourcegraph.com/github.com/Venafi/vcert/-/badge.svg)](https://sourcegraph.com/github.com/Venafi/vcert?badge)
    16  
    17  VCert is a Go library, SDK, and command line utility designed to simplify key generation and enrollment of machine identities
    18  (also known as SSL/TLS certificates and keys) that comply with enterprise security policy by using the
    19  [Venafi Trust Protection Platform](https://www.venafi.com/platform/trust-protection-platform) 
    20  or [Venafi Control Plane](https://www.venafi.com/venaficloud) or [Venafi Firefly](https://venafi.com/firefly/).
    21  
    22  See [VCert CLI for Venafi Trust Protection Platform](README-CLI-PLATFORM.md) or
    23  [VCert CLI for Venafi Control Plane](README-CLI-CLOUD.md) or [VCert CLI for Venafi Firefly](README-CLI-FIREFLY.md) 
    24  to get started with the command line utility.
    25  
    26  #### Compatibility
    27  
    28  VCert releases are tested using the latest version of Trust Protection Platform. General functionality of the
    29  [latest VCert release](../../releases/latest) should be compatible with Trust Protection Platform 17.3 or higher.
    30  Custom Fields and Instance Tracking require TPP 18.2 or higher, and Token Authentication requires TPP 20.1 or higher.
    31  
    32  ## Developer Setup
    33  
    34  1. Configure your Go environment according to https://golang.org/doc/install.
    35  2. Verify that GOPATH environment variable is set correctly
    36  3. Download the source code:
    37     ```sh
    38     go get github.com/Venafi/vcert/v5
    39     ```
    40     
    41     or pre Go 1.13
    42  
    43     ```sh
    44     git clone https://github.com/Venafi/vcert.git $GOPATH/src/github.com/Venafi/vcert/v5
    45     ```
    46  
    47     Go 1.11 with go modules enabled or go 1.13 and up make sure to clone outside of `$GOPATH/src`
    48     ```sh
    49     git clone https://github.com/Venafi/vcert.git
    50     ```
    51  
    52  4. Build the command line utilities for Linux, macOS, and Windows:
    53     ```sh
    54     make build
    55     ```
    56  
    57  ## Using VCert to integrate Venafi with your application
    58  
    59  For code samples of programmatic use, please review the files in [examples folder](./examples).
    60  
    61  ### Common part
    62  1. In your `main.go` file, make the following import declarations:  
    63     ```golang
    64     import (
    65         "github.com/Venafi/vcert/v5"
    66         "github.com/Venafi/vcert/v5/pkg/certificate"
    67         "github.com/Venafi/vcert/v5/pkg/endpoint"
    68     )
    69     ```
    70  2. Create a configuration object of type `&vcert.Config` that specifies the Venafi connection details. Solutions are 
    71  typically designed to get those details from a secrets vault, .ini file, environment variables, or command line parameters.
    72  
    73  ### Enroll certificate
    74  1. Instantiate a client by calling the `NewClient` method of the vcert class with the configuration object.
    75  2. Compose a certificate request object of type `&certificate.Request`.
    76  3. Generate a key pair and CSR for the certificate request by calling the `GenerateRequest` method of the client.
    77  4. Submit the request by passing the certificate request object to the `RequestCertificate` method of the client.
    78  5. Use the request ID to pickup the certificate using the `RetrieveCertificate` method of the client.
    79  
    80  ### New TLS listener for domain
    81  1. Call `vcert.Config` method `NewListener` with list of domains as arguments. 
    82  For example `("test.example.com:8443", "example.com")`
    83  2. Use gotten `net.Listener` as argument to built-in `http.Serve` or other https servers. 
    84  
    85  Samples are in a state where you can build/execute them using the following commands (after setting the environment 
    86  variables discussed later):
    87  ```sh
    88  go build -o cli ./example
    89  go test -v ./example -run TestRequestCertificate
    90  ```
    91  
    92  ## Prerequisites for using with Trust Protection Platform
    93  
    94  1. A user account that has been granted WebSDK Access
    95  2. A folder (zone) where the user has been granted the following permissions: `View`, `Read`, `Write`, `Create`, 
    96  `Revoke` (for the revoke action), and `Private Key Read` (for the pickup action when CSR is service generated)
    97  3. Policy applied to the folder which specifies:
    98      1. CA Template that Trust Protection Platform will use to enroll certificate requests submitted by VCert
    99      2. Subject DN values for Organizational Unit (OU), Organization (O), City (L), State (ST) and Country (C)
   100      3. Management Type not locked or locked to 'Enrollment'
   101      4. Certificate Signing Request (CSR) Generation unlocked or not locked to 'Service Generated CSR'
   102      5. Generate Key/CSR on Application not locked or locked to 'No'
   103      6. (Recommended) Disable Automatic Renewal set to 'Yes'
   104      7. (Recommended) Key Bit Strength set to 2048 or higher
   105      8. (Recommended) Domain Whitelisting policy appropriately assigned
   106  
   107  The requirement for the CA Template to be assigned by policy follows a long-standing Venafi best practice 
   108  which also met our design objective to keep the certificate request process simple for VCert users. 
   109  If you require the ability to specify the CA Template with the request you can use the TPP REST APIs 
   110  but please be advised this goes against Venafi recommendations.
   111  
   112  ## Testing with Trust Protection Platform and Venafi Control Plane
   113  
   114  Unit tests:
   115  ```sh
   116  make test
   117  ```
   118  
   119  Integration tests for Trust Protection Platform and Venafi Control Plane require access to those products. Environment 
   120  variables are used to specify required settings including credentials.  The Venafi Control Plane API key and zone value
   121  fragments (i.e. `Application Name`\\`Issuing Template API Alias`) are readily available in the web interface.
   122  
   123  ```sh
   124  export TPP_URL=https://tpp.venafi.example/vedsdk
   125  export TPP_USER=tpp-user
   126  export TPP_PASSWORD=tpp-password
   127  export TPP_ZONE='some\suggested_policy'
   128  export TPP_ZONE_RESTRICTED='some\locked_policy'
   129  export TPP_ZONE_ECDSA='some\ecdsa_policy'
   130  
   131  make tpp_test
   132  ```
   133  
   134  ```sh
   135  export CLOUD_URL=https://api.venafi.cloud/v1
   136  export CLOUD_APIKEY=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
   137  export CLOUD_ZONE='My Application\Permissive CIT'
   138  export CLOUD_ZONE_RESTRICTED='Your Application\Restrictive CIT'
   139  
   140  make cloud_test
   141  ```
   142  
   143  Command line utility tests make use of [Cucumber & Aruba](https://github.com/cucumber/aruba) feature files.
   144  
   145  - To run tests for all features in parallel:
   146     ```sh
   147     make cucumber
   148     ```
   149    
   150  - To run tests only for a specific feature:
   151    ```sh
   152    make cucumber FEATURE=./features/basic/version.feature
   153    ```
   154    Available features are: 
   155    - `basic`
   156    - `config`
   157    - `enroll`
   158    - `format`
   159    - `gencsr`
   160    - `renew`
   161    - `revoke`
   162  
   163  When run, these tests will be executed in their own Docker container using the Ruby version of Cucumber.  
   164  The completed test run will report on the number of test scenarios and steps that passed, failed, or were skipped. 
   165  
   166  ## Playbook functionality
   167  
   168  For detailed explanations about the playbook and how it is build please check here: [Readme Playbook](./README-PLAYBOOK.md)
   169  
   170  ## Contributing to VCert
   171  
   172  Venafi welcomes contributions from the developer community.
   173  
   174  1. Fork it to your account (https://github.com/Venafi/vcert/fork)
   175  2. Clone your fork:
   176     ```sh
   177     git clone git@github.com:youracct/vcert.git
   178     ```
   179  3. Create a feature branch:
   180     ```sh
   181     git checkout -b your-branch-name
   182     ```
   183  4. Implement and test your changes
   184  5. Commit your changes:
   185     ```sh
   186     git commit -am 'Added some cool functionality'
   187     ```
   188  6. Push to the branch
   189     ```sh
   190     git push origin your-branch-name
   191     ```
   192  7. Create a new Pull Request at https://github.com/youracct/vcert/pull/new/your-branch-name
   193  
   194  ## License
   195  
   196  Copyright © Venafi, Inc. All rights reserved.
   197  
   198  VCert is licensed under the Apache License, Version 2.0. See [LICENSE](./LICENSE) for the full license text.
   199  
   200  Please direct questions/comments to opensource@venafi.com.