Browse code

Propagate the desired CA certificate and CAConfig ForceRotate parameter in the Docker REST APIs when viewing or updating the swarm spec info, and also propagate the desired CA key in the Docker REST APIs when updating swarm spec info only (it is not available for viewing).

Signed-off-by: Ying Li <ying.li@docker.com>

Ying Li authored on 2017/05/03 06:58:57
Showing 4 changed files
... ...
@@ -1886,6 +1886,14 @@ definitions:
1886 1886
                 CACert:
1887 1887
                   description: "The root CA certificate (in PEM format) this external CA uses to issue TLS certificates (assumed to be to the current swarm root CA certificate if not provided)."
1888 1888
                   type: "string"
1889
+          SigningCACert:
1890
+            description: "The desired signing CA certificate for all swarm node TLS leaf certificates, in PEM format."
1891
+            type: "string"
1892
+          SigningCAKey:
1893
+            description: "The desired signing CA key for all swarm node TLS leaf certificates, in PEM format."
1894
+            type: "string"
1895
+          ForceRotate:
1896
+            description: "An integer whose purpose is to force swarm to generate a new signing CA certificate and key, if none have been specified in `SigningCACert` and `SigningCAKey`"
1889 1897
       EncryptionConfig:
1890 1898
         description: "Parameters related to encryption-at-rest."
1891 1899
         type: "object"
... ...
@@ -109,6 +109,16 @@ type CAConfig struct {
109 109
 	// ExternalCAs is a list of CAs to which a manager node will make
110 110
 	// certificate signing requests for node certificates.
111 111
 	ExternalCAs []*ExternalCA `json:",omitempty"`
112
+
113
+	// SigningCACert and SigningCAKey specify the desired signing root CA and
114
+	// root CA key for the swarm.  When inspecting the cluster, the key will
115
+	// be redacted.
116
+	SigningCACert string `json:",omitempty"`
117
+	SigningCAKey  string `json:",omitempty"`
118
+
119
+	// If this value changes, and there is no specified signing cert and key,
120
+	// then the swarm is forced to generate a new root certificate ane key.
121
+	ForceRotate uint64 `json:",omitempty"`
112 122
 }
113 123
 
114 124
 // ExternalCAProtocol represents type of external CA.
... ...
@@ -30,6 +30,11 @@ func SwarmFromGRPC(c swarmapi.Cluster) types.Swarm {
30 30
 				EncryptionConfig: types.EncryptionConfig{
31 31
 					AutoLockManagers: c.Spec.EncryptionConfig.AutoLockManagers,
32 32
 				},
33
+				CAConfig: types.CAConfig{
34
+					// do not include the signing CA key (it should already be redacted via the swarm APIs)
35
+					SigningCACert: string(c.Spec.CAConfig.SigningCACert),
36
+					ForceRotate:   c.Spec.CAConfig.ForceRotate,
37
+				},
33 38
 			},
34 39
 			TLSInfo: types.TLSInfo{
35 40
 				TrustRoot: string(c.RootCA.CACert),
... ...
@@ -114,6 +119,14 @@ func MergeSwarmSpecToGRPC(s types.Spec, spec swarmapi.ClusterSpec) (swarmapi.Clu
114 114
 	if s.CAConfig.NodeCertExpiry != 0 {
115 115
 		spec.CAConfig.NodeCertExpiry = gogotypes.DurationProto(s.CAConfig.NodeCertExpiry)
116 116
 	}
117
+	if s.CAConfig.SigningCACert != "" {
118
+		spec.CAConfig.SigningCACert = []byte(s.CAConfig.SigningCACert)
119
+	}
120
+	if s.CAConfig.SigningCAKey != "" {
121
+		// do prpagate the signing CA key here because we want to provide it TO the swarm APIs
122
+		spec.CAConfig.SigningCAKey = []byte(s.CAConfig.SigningCAKey)
123
+	}
124
+	spec.CAConfig.ForceRotate = s.CAConfig.ForceRotate
117 125
 
118 126
 	for _, ca := range s.CAConfig.ExternalCAs {
119 127
 		protocol, ok := swarmapi.ExternalCA_CAProtocol_value[strings.ToUpper(string(ca.Protocol))]
... ...
@@ -19,11 +19,14 @@ keywords: "API, Docker, rcli, REST, documentation"
19 19
 
20 20
 * `GET /info` now returns the list of supported logging drivers, including plugins.
21 21
 * `GET /info` and `GET /swarm` now returns the cluster-wide swarm CA info if the node is in a swarm: the cluster root CA certificate, and the cluster TLS
22
- leaf certificate issuer's subject and public key.
22
+ leaf certificate issuer's subject and public key. It also displays the desired CA signing certificate, if any was provided as part of the spec.
23 23
 * `POST /build/` now (when not silent) produces an `Aux` message in the JSON output stream with payload `types.BuildResult` for each image produced. The final such message will reference the image resulting from the build.
24 24
 * `GET /nodes` and `GET /nodes/{id}` now returns additional information about swarm TLS info if the node is part of a swarm: the trusted root CA, and the
25 25
  issuer's subject and public key.
26 26
 * `GET /distribution/(name)/json` is a new endpoint that returns a JSON output stream with payload `types.DistributionInspect` for an image name. It includes a descriptor with the digest, and supported platforms retrieved from directly contacting the registry.
27
+* `POST /swarm/update` now accepts 3 additional parameters as part of the swarm spec's CA configuration; the desired CA certificate for
28
+ the swarm, the desired CA key for the swarm (if not using an external certificate), and an optional parameter to force swarm to
29
+ generate and rotate to a new CA certificate/key pair.
27 30
 
28 31
 ## v1.29 API changes
29 32