()
| 167 | } |
| 168 | |
| 169 | func getPublicFromConfig() *asymmetric.PublicKey { |
| 170 | configFile = utils.HomeDirExpand(configFile) |
| 171 | |
| 172 | var err error |
| 173 | // load config |
| 174 | if conf.GConf, err = conf.LoadConfig(configFile); err != nil { |
| 175 | ConsoleLog.WithError(err).Error("load config file failed") |
| 176 | SetExitStatus(1) |
| 177 | ExitIfErrors() |
| 178 | } |
| 179 | |
| 180 | //if config has public, use it |
| 181 | for _, node := range conf.GConf.KnownNodes { |
| 182 | if node.ID == conf.GConf.ThisNodeID { |
| 183 | if node.PublicKey != nil { |
| 184 | ConsoleLog.Infof("use public key in config file: %s", configFile) |
| 185 | return node.PublicKey |
| 186 | } |
| 187 | break |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | //use config specific private key file(already init by configInit()) |
| 192 | ConsoleLog.Infof("generate public key directly from private key: %s", conf.GConf.PrivateKeyFile) |
| 193 | privateKey, err := kms.LoadPrivateKey(conf.GConf.PrivateKeyFile, []byte(password)) |
| 194 | if err != nil { |
| 195 | ConsoleLog.WithError(err).Error("load private key file failed") |
| 196 | SetExitStatus(1) |
| 197 | ExitIfErrors() |
| 198 | } |
| 199 | return privateKey.PubKey() |
| 200 | } |
| 201 | |
| 202 | func storeDSN(dsnArray []string) { |
| 203 | dsnFilePath := path.Join(conf.GConf.WorkingRoot, ".dsn") |
no test coverage detected