Example #1
0
func (c *Config) validateMetadata(body string) (signingCert []x509.Certificate) {
	validator, err := signedxml.NewValidator(body)
	if err != nil {
		panic(err)
	}
	err = validator.Validate()
	if err != nil {
		panic(err)
	}

	certs := validator.Certificates
	return certs
}
Example #2
0
func testValidator() {
	xmlFile, err := os.Open("../testdata/valid-saml.xml")
	if err != nil {
		fmt.Println("Error opening file:", err)
		return
	}
	defer xmlFile.Close()

	xmlBytes, _ := ioutil.ReadAll(xmlFile)

	validator, err := signedxml.NewValidator(string(xmlBytes))
	if err != nil {
		fmt.Printf("Validation Error: %s", err)
	} else {
		err = validator.Validate()
		if err != nil {
			fmt.Printf("Validation Error: %s", err)
		} else {
			fmt.Println("Example Validation Succeeded")
		}
	}
}
Example #3
0
func (w *WSFed) validateSignedXML(wresult string) error {
	validator, err := signedxml.NewValidator(wresult)
	if err != nil {
		return err
	}

	err = validator.Validate()
	if err != nil {
		return err
	}

	cert := validator.SigningCert()

	for _, c := range w.config.TrustedCerts {
		if c.Equal(&cert) {
			return nil
		}
	}

	return errors.New("go-wsfed: The certificate used to sign the response was " +
		"not found in WSFed.config.TrustedCerts")
}