//Massage a cert and key into a usable JSON payload.
Massage a cert and key into a usable JSON payload.
// Massage a cert and key into a usable JSON payload .
func makeRFCertPayload(vendor string, cert bmcCertData, certURI string, certType string) []byte {
	var pld CertificatePayload
	var certStr string
	certStr = hms_certs.NewlineToTuple(cert.Cert)
	if cert.Key != "" {
		certStr = certStr + "\\n" + hms_certs.NewlineToTuple(cert.Key)
	}
	if vendor == VendorHPE {
		pld.Certificate = &certStr
	} else {
		pld.CertificateString = &certStr
	}
	if certURI != "" {
		pld.CertificateUri = &CertificateURI{Uri: certURI}
	}
	if certType != "" {
		pld.CertificateType = &certType
	}
	ba, _ := json.Marshal(&pld)
	st := strings.Replace(string(ba), "\\\\", "\\", -1)
	return []byte(st)
}
func makeRFCertPayload ( vendor string , cert bmcCertData , certURI string , certType string ) [ ] byte { var pld CertificatePayload var certStr string certStr = hms_certs . NewlineToTuple ( cert . Cert ) if cert . Key != " " { certStr = certStr + " \\ " + hms_certs . NewlineToTuple ( cert . Key ) } if vendor == VendorHPE { pld . Certificate = & certStr } else { pld . CertificateString = & certStr } if certURI != " " { pld . CertificateUri = & CertificateURI { Uri : certURI } } if certType != " " { pld . CertificateType = & certType } ba , _ := json . Marshal ( & pld ) st := strings . Replace ( string ( ba ) , " \\ \\ " , " \\ " , - 1 ) return [ ] byte ( st ) }
Massage a cert and key into a usable JSON payload.
Massage a cert and key into a usable JSON payload .
//Replace all CRLF with literal "\n" tuples in the cert and key. //TODO: only take the first one if multiple certs? //The #$%^@!! marshaller escapes '\n' sequences into '\\n'.  This is //hacky, but it works.