gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/pkg/test/resource/v3/secret.go (about) 1 // Copyright 2019 Envoyproxy Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package resource 16 17 import ( 18 core "gitee.com/ks-custle/core-gm/go-control-plane/envoy/config/core/v3" 19 auth "gitee.com/ks-custle/core-gm/go-control-plane/envoy/extensions/transport_sockets/tls/v3" 20 ) 21 22 const ( 23 tlsName = "tlssecret" 24 25 rootName = "rootsecret" 26 27 privateKey = `-----BEGIN RSA PRIVATE KEY----- 28 MIIEowIBAAKCAQEAsU265Ev3yVUAGds4qorN/QH0acOPO/gO7diGcfZ7QSQvjBUn 29 TGO00EquFyqU9ameU0X1YPUWMsATE7HEQZFV7dtiQdN7OATNMIWgAH4Rhl6zLbc0 30 sh2MpxJQqakE6klZo5ZDRuXm11o8tdM9+kj2m9SlwtrflXd+jQ1afvsgvUP1FsA5 31 rZfOk0+WBzWymJDEsSZELQVh6LM94Y/0x55vj0dx+jtweGpsBAbLwS9SWqk1ynKr 32 6K7ZYiUnfM1jTqIF4NTwfe79lfttXZZHLBjtm2UZQZWz4R1VRQP/yoFVWXUMydhg 33 fUsnBYoWBCPgLRDGdf6+/NmIcMOUdhAFQmd5YQIDAQABAoIBAD3bMGiVWE0VKoPa 34 x1o4MsUh+XMslrwFPrAb6ku4Aignx67Hcn5kCqDgbPwIDw/lrSbAMWsyFhx+hilI 35 y39UhPYGo7DzZvmUM0HKXJfPY63NPBWm5Ot/A6MF8L5ACUbzcCJyOeZyLqbTBHsq 36 x2SaL+8NsQbZ9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b/sM9FurtVKuVhu2qeAFQXat0uKop76fZV56XVrh 53 -----END RSA PRIVATE KEY-----` 54 55 privateChain = `-----BEGIN CERTIFICATE----- 56 MIIDWzCCAkOgAwIBAgIQcojbQweHMt1XQLs8eIpyqTANBgkqhkiG9w0BAQsFADBF 57 MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 58 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMB4XDTE4MDgwOTIzMDg0MloXDTE5MDgwOTIz 59 MDg0MlowEzERMA8GA1UEChMISnVqdSBvcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IB 60 DwAwggEKAoIBAQCxTbrkS/fJVQAZ2ziqis39AfRpw487+A7t2IZx9ntBJC+MFSdM 61 Y7TQSq4XKpT1qZ5TRfVg9RYywBMTscRBkVXt22JB03s4BM0whaAAfhGGXrMttzSy 62 HYynElCpqQTqSVmjlkNG5ebXWjy10z36SPab1KXC2t+Vd36NDVp++yC9Q/UWwDmt 63 l86TT5YHNbKYkMSxJkQtBWHosz3hj/THnm+PR3H6O3B4amwEBsvBL1JaqTXKcqvo 64 rtliJSd8zWNOogXg1PB97v2V+21dlkcsGO2bZRlBlbPhHVVFA//KgVVZdQzJ2GB9 65 SycFihYEI+AtEMZ1/r782Yhww5R2EAVCZ3lhAgMBAAGjeTB3MA4GA1UdDwEB/wQE 66 AwIFoDAMBgNVHRMBAf8EAjAAMB8GA1UdIwQYMBaAFCudfB/DxIfxp92elExpHJfN 67 eMliMDYGA1UdEQQvMC2GK3NwaWZmZTovL2NsdXN0ZXIubG9jYWwvbnMvZGVmYXVs 68 dC9zYS9zZXJ2ZXIwDQYJKoZIhvcNAQELBQADggEBAKQuLmnWXotaiA8SiV7QYWWw 69 aAHnlNS/HgvUmgNYort+IlhCb0a4098ncmnP0fyyuQloElEWKE/00/d9eLiocWHt 70 tKhftYQ6Z9DY5nNerbb3uv8fKrV91z5paFiHfXotw2e1zmtjP3Guve9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814yWIw 89 DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAZ+x0ppSUYQUw6FCVFjkp 90 C99bX5O/jxRXoPCmsqh+NoOjvni65IKR7ilxDXLcrXaSNovopWDo4Fz7fQaR9xwk 91 0fIgu+JNdq72LmHlrCtjlD0Es08R+KUHWgpbHxaKq77+Ie/9w+pY3uDQz0dMy/yN 92 yw3pH4By0lYwKt4QzRtA9btCiLYivReV9b+3P2P5IR+BLtLXt4j8LvstoJYhagUn 93 L1qakOGqxFLL0P3CuulGACAH0jRRIhrREKnj3rVFGtdl4APafBn9XnJwzlwwj/GU 94 y5E2qAmEqYO6m1rVPeeE0kjP5rIOEH5qQKpxtJ2/gAqc0OOmbFrnbfOWGUNkWn7X 95 yA== 96 -----END CERTIFICATE-----` 97 ) 98 99 // MakeSecrets generates an SDS secret 100 func MakeSecrets(tlsName, rootName string) []*auth.Secret { 101 return []*auth.Secret{ 102 { 103 Name: tlsName, 104 Type: &auth.Secret_TlsCertificate{ 105 TlsCertificate: &auth.TlsCertificate{ 106 PrivateKey: &core.DataSource{ 107 Specifier: &core.DataSource_InlineBytes{InlineBytes: []byte(privateKey)}, 108 }, 109 CertificateChain: &core.DataSource{ 110 Specifier: &core.DataSource_InlineBytes{InlineBytes: []byte(privateChain)}, 111 }, 112 }, 113 }, 114 }, 115 { 116 Name: rootName, 117 Type: &auth.Secret_ValidationContext{ 118 ValidationContext: &auth.CertificateValidationContext{ 119 TrustedCa: &core.DataSource{ 120 Specifier: &core.DataSource_InlineBytes{InlineBytes: []byte(rootCert)}, 121 }, 122 }, 123 }, 124 }, 125 } 126 }