k8s.io/apiserver@v0.31.1/pkg/server/dynamiccertificates/cert_key.go (about) 1 /* 2 Copyright 2019 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package dynamiccertificates 18 19 import ( 20 "bytes" 21 ) 22 23 // certKeyContent holds the content for the cert and key 24 type certKeyContent struct { 25 cert []byte 26 key []byte 27 } 28 29 func (c *certKeyContent) Equal(rhs *certKeyContent) bool { 30 if c == nil || rhs == nil { 31 return c == rhs 32 } 33 34 return bytes.Equal(c.key, rhs.key) && bytes.Equal(c.cert, rhs.cert) 35 } 36 37 // sniCertKeyContent holds the content for the cert and key as well as any explicit names 38 type sniCertKeyContent struct { 39 certKeyContent 40 sniNames []string 41 } 42 43 func (c *sniCertKeyContent) Equal(rhs *sniCertKeyContent) bool { 44 if c == nil || rhs == nil { 45 return c == rhs 46 } 47 48 if len(c.sniNames) != len(rhs.sniNames) { 49 return false 50 } 51 52 for i := range c.sniNames { 53 if c.sniNames[i] != rhs.sniNames[i] { 54 return false 55 } 56 } 57 58 return c.certKeyContent.Equal(&rhs.certKeyContent) 59 }