Example #1
0
// Verify the messagFile with the signatureFile by the certificate
func Verify(pemFile, signatureFile, messageFile string) error {
	path, err := CheckInstalled()
	app.CheckPanic(err)

	cmd := exec.Command(path, "smime", "-verify", "-inform", "der", "-in", signatureFile, "-content", messageFile, "-certfile", pemFile, "-noverify")
	if app.IsDebugRunmode() {
		cmd.Stderr = os.Stderr
	}

	err = cmd.Run()
	app.CheckPanic(err)

	return nil
}
Example #2
0
// ExportPubkey expors the public key from certificate
func ExportPubkey(pemFile, pubkeyFile string) error {
	path, err := CheckInstalled()
	app.CheckPanic(err)

	cmd := exec.Command(path, "x509", "-pubkey", "-noout", "-in", pemFile, "-outform", "pem")
	if app.IsDebugRunmode() {
		cmd.Stderr = os.Stderr
	}

	err = cmd.Run()
	app.CheckPanic(err)

	pubkey, _ := cmd.Output()

	err = ioutil.WriteFile(pubkeyFile, pubkey, 0644)
	app.CheckPanic(err)

	return nil
}
Example #3
0
func InitDB(init bool, prefill bool) {
	orm.Debug = app.IsDebugRunmode()
	orm.DefaultTimeLoc = time.Local

	orm.RegisterModel(new(Contrep), new(Document), new(Component))
	orm.RegisterDataBase("default", beego.AppConfig.String(DB_DRIVER), beego.AppConfig.String(DB_CONN))

	err := orm.RunSyncdb("default", init, true)
	app.CheckPanic(err)

	Orm = orm.NewOrm()
	Orm.Using("default")

	if prefill {
		contrep := &Contrep{Name: "MP", Desc: "Description of MP content repository", IsOnline: true, IsCertChecked: true}
		_, err := Orm.Insert(contrep)
		app.CheckPanic(err)

		var documents []*Document

		for i := 0; i < 10; i++ {
			document := &Document{Name: "Document #" + strconv.Itoa(i)}
			_, err = Orm.Insert(document)
			app.CheckPanic(err)

			documents = append(documents, document)

			for j := 0; j < 10; j++ {
				component := &Component{Name: "Componet #" + strconv.Itoa(j) + " of Document " + document.Name}
				component.Document = document

				_, err = Orm.Insert(component)
				app.CheckPanic(err)
			}
		}
	}
}