(resp *http.Response)
| 385 | } |
| 386 | |
| 387 | func (c *idCheckingHTTPClient) check(resp *http.Response) error { |
| 388 | if resp.TLS == nil { |
| 389 | return errors.New("security: not TLS") |
| 390 | } |
| 391 | |
| 392 | if len(resp.TLS.PeerCertificates) == 0 { |
| 393 | return errors.New("security: no certificates") |
| 394 | } |
| 395 | |
| 396 | id := protocol.NewDeviceID(resp.TLS.PeerCertificates[0].Raw) |
| 397 | if !id.Equals(c.id) { |
| 398 | return errors.New("security: incorrect device id") |
| 399 | } |
| 400 | |
| 401 | return nil |
| 402 | } |
| 403 | |
| 404 | func (c *idCheckingHTTPClient) Get(ctx context.Context, url string) (*http.Response, error) { |
| 405 | resp, err := c.httpClient.Get(ctx, url) |
no test coverage detected