示例#1
0
文件: utils.go 项目: qinguoan/vulcan
func CreateCrypto(c *cli.Context) (*secure.AesGCM, error) {
	keyPath := c.String("key-path")

	if keyPath == "" {
		usr, err := user.Current()
		if err != nil {
			fmt.Println(err.Error())
		}
		keyPath = usr.HomeDir + "/.rss/key"
	}

	key, err := ioutil.ReadFile(keyPath)
	if err != nil {
		fmt.Printf("Unable to read key file: %s\n%s\n", keyPath, err.Error())
		return nil, err
	}

	secretDecoded, err := base64.StdEncoding.DecodeString(string(key))
	if err != nil {
		fmt.Printf("Error decoding key: %s\n", err)
		return nil, err
	}

	crypto, err := secure.NewAesGCM(secretDecoded)
	if err != nil {
		fmt.Printf("Error creating crypto: %s\n", err)
		return nil, err
	}
	return crypto, nil
}
示例#2
0
文件: main.go 项目: qinguoan/vulcan
func createCrypto(secret string, logger *steno.Logger) *secure.AesGCM {
	secretDecoded, err := base64.StdEncoding.DecodeString(secret)
	if err != nil {
		logger.Errorf("Error decoding route service secret: %s\n", err)
		os.Exit(1)
	}

	crypto, err := secure.NewAesGCM(secretDecoded)
	if err != nil {
		logger.Errorf("Error creating route service crypto: %s\n", err)
		os.Exit(1)
	}
	return crypto
}
示例#3
0
	proxyServer   net.Listener
	accessLog     access_log.AccessLogger
	accessLogFile *test_util.FakeFile
	crypto        secure.Crypto
	cryptoPrev    secure.Crypto
)

func TestProxy(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Proxy Suite")
}

var _ = BeforeEach(func() {
	var err error

	crypto, err = secure.NewAesGCM([]byte("ABCDEFGHIJKLMNOP"))
	Expect(err).NotTo(HaveOccurred())

	cryptoPrev = nil

	conf = config.DefaultConfig()
	conf.TraceKey = "my_trace_key"
	conf.EndpointTimeout = 500 * time.Millisecond
})

var _ = JustBeforeEach(func() {
	var err error
	mbus := fakeyagnats.Connect()
	r = registry.NewRouteRegistry(conf, mbus, new(fakes.FakeRouteReporter))

	fakeEmitter := fake.NewFakeEventEmitter("fake")
	"vulcan/router/common/secure"
	"vulcan/router/route_service"
	"vulcan/router/test_util"
)

var _ = Describe("Route Service Config", func() {
	var (
		config     *route_service.RouteServiceConfig
		crypto     secure.Crypto
		cryptoPrev secure.Crypto
		cryptoKey  = "ABCDEFGHIJKLMNOP"
	)

	BeforeEach(func() {
		var err error
		crypto, err = secure.NewAesGCM([]byte(cryptoKey))
		Expect(err).ToNot(HaveOccurred())
		config = route_service.NewRouteServiceConfig(true, 1*time.Hour, crypto, cryptoPrev)
	})

	AfterEach(func() {
		crypto = nil
		cryptoPrev = nil
		config = nil
	})

	Describe("SetupRouteServiceRequest", func() {
		var (
			request *http.Request
			rsArgs  route_service.RouteServiceArgs
		)