| 242 | } |
| 243 | |
| 244 | func FetchExpectedCAs(ctx context.Context, anc *api.Session, org, realm string) ([]*truststore.CA, error) { |
| 245 | creds, err := anc.FetchCredentials(ctx, org, realm) |
| 246 | if err != nil { |
| 247 | return nil, err |
| 248 | } |
| 249 | |
| 250 | var cas []*truststore.CA |
| 251 | for _, item := range creds { |
| 252 | blk, _ := pem.Decode([]byte(item.TextualEncoding)) |
| 253 | |
| 254 | cert, err := x509.ParseCertificate(blk.Bytes) |
| 255 | if err != nil { |
| 256 | return nil, err |
| 257 | } |
| 258 | |
| 259 | uniqueName := cert.SerialNumber.Text(16) |
| 260 | |
| 261 | ca := &truststore.CA{ |
| 262 | Certificate: cert, |
| 263 | UniqueName: uniqueName, |
| 264 | } |
| 265 | |
| 266 | // TODO: make this variable based on cli.Config |
| 267 | if ca.PublicKeyAlgorithm == x509.Ed25519 { |
| 268 | continue |
| 269 | } |
| 270 | |
| 271 | cas = append(cas, ca) |
| 272 | } |
| 273 | return cas, nil |
| 274 | } |
| 275 | |
| 276 | func FetchLocalDevCAs(ctx context.Context, anc *api.Session) ([]*truststore.CA, error) { |
| 277 | userInfo, err := anc.UserInfo(ctx) |