OLD | NEW |
1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package certconfig | 5 package certconfig |
6 | 6 |
7 import ( | 7 import ( |
8 "crypto/x509" | 8 "crypto/x509" |
9 "fmt" | 9 "fmt" |
10 "io/ioutil" | 10 "io/ioutil" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 // Read the body in its entirety. | 136 // Read the body in its entirety. |
137 blob, err = ioutil.ReadAll(resp.Body) | 137 blob, err = ioutil.ReadAll(resp.Body) |
138 if err != nil { | 138 if err != nil { |
139 return nil, "", transient.Tag.Apply(err) | 139 return nil, "", transient.Tag.Apply(err) |
140 } | 140 } |
141 | 141 |
142 // Transient error? | 142 // Transient error? |
143 if resp.StatusCode >= http.StatusInternalServerError { | 143 if resp.StatusCode >= http.StatusInternalServerError { |
144 logging.Warningf(c, "GET %s - HTTP %d; %q", cfg.CrlUrl, resp.Sta
tusCode, string(blob)) | 144 logging.Warningf(c, "GET %s - HTTP %d; %q", cfg.CrlUrl, resp.Sta
tusCode, string(blob)) |
145 » » return nil, "", errors.Reason("server replied with HTTP %(code)d
"). | 145 » » return nil, "", errors.Reason("server replied with HTTP %d", res
p.StatusCode). |
146 » » » D("code", resp.StatusCode).Tag(transient.Tag).Err() | 146 » » » Tag(transient.Tag).Err() |
147 } | 147 } |
148 | 148 |
149 // Something we don't support or expect? | 149 // Something we don't support or expect? |
150 if resp.StatusCode != http.StatusOK { | 150 if resp.StatusCode != http.StatusOK { |
151 logging.Errorf(c, "GET %s - HTTP %d; %q", cfg.CrlUrl, resp.Statu
sCode, string(blob)) | 151 logging.Errorf(c, "GET %s - HTTP %d; %q", cfg.CrlUrl, resp.Statu
sCode, string(blob)) |
152 return nil, "", fmt.Errorf("unexpected status HTTP %d", resp.Sta
tusCode) | 152 return nil, "", fmt.Errorf("unexpected status HTTP %d", resp.Sta
tusCode) |
153 } | 153 } |
154 | 154 |
155 // Good enough. | 155 // Good enough. |
156 return blob, resp.Header.Get("ETag"), nil | 156 return blob, resp.Header.Get("ETag"), nil |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 214 } |
215 return ds.Put(c, toPut) | 215 return ds.Put(c, toPut) |
216 }, nil) | 216 }, nil) |
217 if err != nil { | 217 if err != nil { |
218 return nil, transient.Tag.Apply(err) | 218 return nil, transient.Tag.Apply(err) |
219 } | 219 } |
220 | 220 |
221 logging.Infof(c, "CRL for %q is updated, entity version is %d", ca.CN, u
pdated.EntityVersion) | 221 logging.Infof(c, "CRL for %q is updated, entity version is %d", ca.CN, u
pdated.EntityVersion) |
222 return updated, nil | 222 return updated, nil |
223 } | 223 } |
OLD | NEW |