本文整理汇总了Golang中github.com/outbrain/orchestrator/go/ssl.AppendKeyPair函数的典型用法代码示例。如果您正苦于以下问题:Golang AppendKeyPair函数的具体用法?Golang AppendKeyPair怎么用?Golang AppendKeyPair使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AppendKeyPair函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Http
// Http starts serving HTTP (api/web) requests
func Http() {
martini.Env = martini.Prod
m := martini.Classic()
if config.Config.HTTPAuthUser != "" {
m.Use(auth.Basic(config.Config.HTTPAuthUser, config.Config.HTTPAuthPassword))
}
m.Use(gzip.All())
// Render html templates from templates directory
m.Use(render.Renderer(render.Options{
Directory: "resources",
Layout: "templates/layout",
HTMLContentType: "text/html",
}))
m.Use(martini.Static("resources/public"))
if config.Config.UseMutualTLS {
m.Use(ssl.VerifyOUs(config.Config.SSLValidOUs))
}
go agent.ContinuousOperation()
log.Infof("Starting HTTP on port %d", config.Config.HTTPPort)
http.API.RegisterRequests(m)
listenAddress := fmt.Sprintf(":%d", config.Config.HTTPPort)
// Serve
if config.Config.UseSSL {
if len(config.Config.SSLCertFile) == 0 {
log.Fatale(errors.New("UseSSL is true but SSLCertFile is unspecified"))
}
if len(config.Config.SSLPrivateKeyFile) == 0 {
log.Fatale(errors.New("UseSSL is true but SSLPrivateKeyFile is unspecified"))
}
log.Info("Starting HTTPS listener")
tlsConfig, err := ssl.NewTLSConfig(config.Config.SSLCAFile, config.Config.UseMutualTLS)
if err != nil {
log.Fatale(err)
}
if err = ssl.AppendKeyPair(tlsConfig, config.Config.SSLCertFile, config.Config.SSLPrivateKeyFile); err != nil {
log.Fatale(err)
}
if err = ssl.ListenAndServeTLS(listenAddress, m, tlsConfig); err != nil {
log.Fatale(err)
}
} else {
log.Info("Starting HTTP listener")
if err := nethttp.ListenAndServe(listenAddress, m); err != nil {
log.Fatale(err)
}
}
log.Info("Web server started")
}
开发者ID:BrianIp,项目名称:orchestrator-agent,代码行数:57,代码来源:http.go
示例2: TestAppendKeyPair
func TestAppendKeyPair(t *testing.T) {
c, err := ssl.NewTLSConfig("", false)
if err != nil {
t.Fatal(err)
}
pemCertFile := writeFakeFile(pemCertificate)
defer syscall.Unlink(pemCertFile)
pemPKFile := writeFakeFile(pemPrivateKey)
defer syscall.Unlink(pemPKFile)
if err := ssl.AppendKeyPair(c, pemCertFile, pemPKFile); err != nil {
t.Errorf("Failed to append certificate and key to tls config: %s", err)
}
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:14,代码来源:ssl_test.go
示例3: SetupMySQLOrchestratorTLS
// Create a TLS configuration from the config supplied CA, Certificate, and Private key.
// Register the TLS config with the mysql drivers as the "orchestrator" config
// Modify the supplied URI to call the TLS config
func SetupMySQLOrchestratorTLS(uri string) (string, error) {
if !orchestratorTLSConfigured {
tlsConfig, err := ssl.NewTLSConfig(config.Config.MySQLOrchestratorSSLCAFile, true)
if err != nil {
return "", log.Fatalf("Can't create TLS configuration for Orchestrator connection %s: %s", uri, err)
}
tlsConfig.InsecureSkipVerify = config.Config.MySQLOrchestratorSSLSkipVerify
if err = ssl.AppendKeyPair(tlsConfig, config.Config.MySQLOrchestratorSSLCertFile, config.Config.MySQLOrchestratorSSLPrivateKeyFile); err != nil {
return "", log.Fatalf("Can't setup TLS key pairs for %s: %s", uri, err)
}
if err = mysql.RegisterTLSConfig("orchestrator", tlsConfig); err != nil {
return "", log.Fatalf("Can't register mysql TLS config for orchestrator: %s", err)
}
orchestratorTLSConfigured = true
}
return fmt.Sprintf("%s&tls=orchestrator", uri), nil
}
开发者ID:maziadi,项目名称:orchestrator,代码行数:20,代码来源:db.go
示例4: SetupMySQLTopologyTLS
// Create a TLS configuration from the config supplied CA, Certificate, and Private key.
// Register the TLS config with the mysql drivers as the "topology" config
// Modify the supplied URI to call the TLS config
// TODO: Way to have password mixed with TLS for various nodes in the topology. Currently everything is TLS or everything is password
func SetupMySQLTopologyTLS(uri string) (string, error) {
if !topologyTLSConfigured {
tlsConfig, err := ssl.NewTLSConfig(config.Config.MySQLTopologySSLCAFile, !config.Config.MySQLTopologySSLSkipVerify)
// Drop to TLS 1.0 for talking to MySQL
tlsConfig.MinVersion = tls.VersionTLS10
if err != nil {
return "", log.Fatalf("Can't create TLS configuration for Topology connection %s: %s", uri, err)
}
tlsConfig.InsecureSkipVerify = config.Config.MySQLTopologySSLSkipVerify
if err = ssl.AppendKeyPair(tlsConfig, config.Config.MySQLTopologySSLCertFile, config.Config.MySQLTopologySSLPrivateKeyFile); err != nil {
return "", log.Fatalf("Can't setup TLS key pairs for %s: %s", uri, err)
}
if err = mysql.RegisterTLSConfig("topology", tlsConfig); err != nil {
return "", log.Fatalf("Can't register mysql TLS config for topology: %s", err)
}
topologyTLSConfigured = true
}
return fmt.Sprintf("%s&tls=topology", uri), nil
}
开发者ID:BrianIp,项目名称:orchestrator,代码行数:23,代码来源:db.go
示例5: agentsHttp
// agentsHttp startes serving agents HTTP or HTTPS API requests
func agentsHttp() {
m := martini.Classic()
m.Use(gzip.All())
m.Use(render.Renderer())
if config.Config.AgentsUseMutualTLS {
m.Use(ssl.VerifyOUs(config.Config.AgentSSLValidOUs))
}
log.Info("Starting agents listener")
go logic.ContinuousAgentsPoll()
http.AgentsAPI.RegisterRequests(m)
// Serve
if config.Config.AgentsUseSSL {
log.Info("Starting agent HTTPS listener")
tlsConfig, err := ssl.NewTLSConfig(config.Config.AgentSSLCAFile, config.Config.AgentsUseMutualTLS)
if err != nil {
log.Fatale(err)
}
tlsConfig.InsecureSkipVerify = config.Config.AgentSSLSkipVerify
if err = ssl.AppendKeyPair(tlsConfig, config.Config.AgentSSLCertFile, config.Config.AgentSSLPrivateKeyFile); err != nil {
log.Fatale(err)
}
if err = ssl.ListenAndServeTLS(config.Config.AgentsServerPort, m, tlsConfig); err != nil {
log.Fatale(err)
}
} else {
log.Info("Starting agent HTTP listener")
if err := nethttp.ListenAndServe(config.Config.AgentsServerPort, m); err != nil {
log.Fatale(err)
}
}
log.Info("Agent server started")
}
开发者ID:rlowe,项目名称:orchestrator,代码行数:37,代码来源:http.go
示例6: standardHttp
// standardHttp starts serving HTTP or HTTPS (api/web) requests, to be used by normal clients
func standardHttp(discovery bool) {
m := martini.Classic()
switch strings.ToLower(config.Config.AuthenticationMethod) {
case "basic":
{
if config.Config.HTTPAuthUser == "" {
// Still allowed; may be disallowed in future versions
log.Warning("AuthenticationMethod is configured as 'basic' but HTTPAuthUser undefined. Running without authentication.")
}
m.Use(auth.Basic(config.Config.HTTPAuthUser, config.Config.HTTPAuthPassword))
}
case "multi":
{
if config.Config.HTTPAuthUser == "" {
// Still allowed; may be disallowed in future versions
log.Fatal("AuthenticationMethod is configured as 'multi' but HTTPAuthUser undefined")
}
m.Use(auth.BasicFunc(func(username, password string) bool {
if username == "readonly" {
// Will be treated as "read-only"
return true
}
return auth.SecureCompare(username, config.Config.HTTPAuthUser) && auth.SecureCompare(password, config.Config.HTTPAuthPassword)
}))
}
default:
{
// We inject a dummy User object because we have function signatures with User argument in api.go
m.Map(auth.User(""))
}
}
m.Use(gzip.All())
// Render html templates from templates directory
m.Use(render.Renderer(render.Options{
Directory: "resources",
Layout: "templates/layout",
HTMLContentType: "text/html",
}))
m.Use(martini.Static("resources/public"))
if config.Config.UseMutualTLS {
m.Use(ssl.VerifyOUs(config.Config.SSLValidOUs))
}
inst.SetMaintenanceOwner(process.ThisHostname)
if discovery {
log.Info("Starting Discovery")
go logic.ContinuousDiscovery()
}
inst.ReadClusterAliases()
log.Info("Registering endpoints")
http.API.RegisterRequests(m)
http.Web.RegisterRequests(m)
// Serve
if config.Config.UseSSL {
log.Info("Starting HTTPS listener")
tlsConfig, err := ssl.NewTLSConfig(config.Config.SSLCAFile, config.Config.UseMutualTLS)
if err != nil {
log.Fatale(err)
}
tlsConfig.InsecureSkipVerify = config.Config.SSLSkipVerify
if err = ssl.AppendKeyPair(tlsConfig, config.Config.SSLCertFile, config.Config.SSLPrivateKeyFile); err != nil {
log.Fatale(err)
}
if err = ssl.ListenAndServeTLS(config.Config.ListenAddress, m, tlsConfig); err != nil {
log.Fatale(err)
}
} else {
log.Info("Starting HTTP listener")
if err := nethttp.ListenAndServe(config.Config.ListenAddress, m); err != nil {
log.Fatale(err)
}
}
log.Info("Web server started")
}
开发者ID:rlowe,项目名称:orchestrator,代码行数:81,代码来源:http.go
注:本文中的github.com/outbrain/orchestrator/go/ssl.AppendKeyPair函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论