authority.go 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. package authority
  2. import (
  3. "context"
  4. "crypto"
  5. "crypto/sha256"
  6. "crypto/x509"
  7. "encoding/hex"
  8. "log"
  9. "strings"
  10. "sync"
  11. "time"
  12. "github.com/pkg/errors"
  13. "github.com/smallstep/certificates/authority/admin"
  14. adminDBNosql "github.com/smallstep/certificates/authority/admin/db/nosql"
  15. "github.com/smallstep/certificates/authority/administrator"
  16. "github.com/smallstep/certificates/authority/cache"
  17. "github.com/smallstep/certificates/authority/config"
  18. "github.com/smallstep/certificates/authority/provisioner"
  19. "github.com/smallstep/certificates/cas"
  20. casapi "github.com/smallstep/certificates/cas/apiv1"
  21. "github.com/smallstep/certificates/db"
  22. "github.com/smallstep/certificates/kms"
  23. kmsapi "github.com/smallstep/certificates/kms/apiv1"
  24. "github.com/smallstep/certificates/kms/sshagentkms"
  25. "github.com/smallstep/certificates/scep"
  26. "github.com/smallstep/certificates/templates"
  27. "github.com/smallstep/nosql"
  28. "go.step.sm/crypto/pemutil"
  29. "go.step.sm/linkedca"
  30. "golang.org/x/crypto/ssh"
  31. )
  32. // Authority implements the Certificate Authority internal interface.
  33. type Authority struct {
  34. config *config.Config
  35. keyManager kms.KeyManager
  36. provisioners Provisioners
  37. admins Admins
  38. db db.AuthDB
  39. adminDB admin.DB
  40. templates *templates.Templates
  41. linkedCAToken string
  42. // X509 CA
  43. password []byte
  44. issuerPassword []byte
  45. x509CAService cas.CertificateAuthorityService
  46. rootX509Certs []*x509.Certificate
  47. rootX509CertPool *x509.CertPool
  48. federatedX509Certs []*x509.Certificate
  49. certificates *sync.Map
  50. x509Enforcers []provisioner.CertificateEnforcer
  51. // SCEP CA
  52. scepService *scep.Service
  53. // SSH CA
  54. sshHostPassword []byte
  55. sshUserPassword []byte
  56. sshCAUserCertSignKey ssh.Signer
  57. sshCAHostCertSignKey ssh.Signer
  58. sshCAUserCerts []ssh.PublicKey
  59. sshCAHostCerts []ssh.PublicKey
  60. sshCAUserFederatedCerts []ssh.PublicKey
  61. sshCAHostFederatedCerts []ssh.PublicKey
  62. // Do not re-initialize
  63. initOnce bool
  64. startTime time.Time
  65. // Custom functions
  66. sshBastionFunc func(ctx context.Context, user, hostname string) (*config.Bastion, error)
  67. sshCheckHostFunc func(ctx context.Context, principal string, tok string, roots []*x509.Certificate) (bool, error)
  68. sshGetHostsFunc func(ctx context.Context, cert *x509.Certificate) ([]config.Host, error)
  69. getIdentityFunc provisioner.GetIdentityFunc
  70. authorizeRenewFunc provisioner.AuthorizeRenewFunc
  71. authorizeSSHRenewFunc provisioner.AuthorizeSSHRenewFunc
  72. cachePool cache.Pool
  73. adminMutex sync.RWMutex
  74. }
  75. // New creates and initiates a new Authority type.
  76. func New(cfg *config.Config, opts ...Option) (*Authority, error) {
  77. err := cfg.Validate()
  78. if err != nil {
  79. return nil, err
  80. }
  81. var a = &Authority{
  82. config: cfg,
  83. certificates: new(sync.Map),
  84. }
  85. // Apply options.
  86. for _, fn := range opts {
  87. if err := fn(a); err != nil {
  88. return nil, err
  89. }
  90. }
  91. // Initialize authority from options or configuration.
  92. if err := a.init(); err != nil {
  93. return nil, err
  94. }
  95. return a, nil
  96. }
  97. // NewEmbedded initializes an authority that can be embedded in a different
  98. // project without the limitations of the config.
  99. func NewEmbedded(opts ...Option) (*Authority, error) {
  100. a := &Authority{
  101. config: &config.Config{},
  102. certificates: new(sync.Map),
  103. }
  104. // Apply options.
  105. for _, fn := range opts {
  106. if err := fn(a); err != nil {
  107. return nil, err
  108. }
  109. }
  110. // Validate required options
  111. switch {
  112. case a.config == nil:
  113. return nil, errors.New("cannot create an authority without a configuration")
  114. case len(a.rootX509Certs) == 0 && a.config.Root.HasEmpties():
  115. return nil, errors.New("cannot create an authority without a root certificate")
  116. case a.x509CAService == nil && a.config.IntermediateCert == "":
  117. return nil, errors.New("cannot create an authority without an issuer certificate")
  118. case a.x509CAService == nil && a.config.IntermediateKey == "":
  119. return nil, errors.New("cannot create an authority without an issuer signer")
  120. }
  121. // Initialize config required fields.
  122. a.config.Init()
  123. // Initialize authority from options or configuration.
  124. if err := a.init(); err != nil {
  125. return nil, err
  126. }
  127. return a, nil
  128. }
  129. // reloadAdminResources reloads admins and provisioners from the DB.
  130. func (a *Authority) reloadAdminResources(ctx context.Context) error {
  131. var (
  132. provList provisioner.List
  133. adminList []*linkedca.Admin
  134. )
  135. if a.config.AuthorityConfig.EnableAdmin {
  136. provs, err := a.adminDB.GetProvisioners(ctx)
  137. if err != nil {
  138. return admin.WrapErrorISE(err, "error getting provisioners to initialize authority")
  139. }
  140. provList, err = provisionerListToCertificates(provs)
  141. if err != nil {
  142. return admin.WrapErrorISE(err, "error converting provisioner list to certificates")
  143. }
  144. adminList, err = a.adminDB.GetAdmins(ctx)
  145. if err != nil {
  146. return admin.WrapErrorISE(err, "error getting admins to initialize authority")
  147. }
  148. } else {
  149. provList = a.config.AuthorityConfig.Provisioners
  150. adminList = a.config.AuthorityConfig.Admins
  151. }
  152. provisionerConfig, err := a.generateProvisionerConfig(ctx)
  153. if err != nil {
  154. return admin.WrapErrorISE(err, "error generating provisioner config")
  155. }
  156. // Create provisioner collection.
  157. provClxn := provisioner.NewCollection(provisionerConfig)
  158. for _, p := range provList {
  159. if err := p.Init(provisionerConfig); err != nil {
  160. return err
  161. }
  162. if err := provClxn.Store(p); err != nil {
  163. return err
  164. }
  165. }
  166. // Create admin collection.
  167. adminClxn := administrator.NewCollection(provClxn)
  168. for _, adm := range adminList {
  169. p, ok := provClxn.Load(adm.ProvisionerId)
  170. if !ok {
  171. return admin.NewErrorISE("provisioner %s not found when loading admin %s",
  172. adm.ProvisionerId, adm.Id)
  173. }
  174. if err := adminClxn.Store(adm, p); err != nil {
  175. return err
  176. }
  177. }
  178. a.config.AuthorityConfig.Provisioners = provList
  179. a.provisioners = provClxn
  180. a.config.AuthorityConfig.Admins = adminList
  181. a.admins = adminClxn
  182. return nil
  183. }
  184. // init performs validation and initializes the fields of an Authority struct.
  185. func (a *Authority) init() error {
  186. // Check if handler has already been validated/initialized.
  187. if a.initOnce {
  188. return nil
  189. }
  190. var err error
  191. // Set password if they are not set.
  192. var configPassword []byte
  193. if a.config.Password != "" {
  194. configPassword = []byte(a.config.Password)
  195. }
  196. if configPassword != nil && a.password == nil {
  197. a.password = configPassword
  198. }
  199. if a.sshHostPassword == nil {
  200. a.sshHostPassword = a.password
  201. }
  202. if a.sshUserPassword == nil {
  203. a.sshUserPassword = a.password
  204. }
  205. // Automatically enable admin for all linked cas.
  206. if a.linkedCAToken != "" {
  207. a.config.AuthorityConfig.EnableAdmin = true
  208. }
  209. // Initialize step-ca Database if it's not already initialized with WithDB.
  210. // If a.config.DB is nil then a simple, barebones in memory DB will be used.
  211. if a.db == nil {
  212. if a.db, err = db.New(a.config.DB); err != nil {
  213. return err
  214. }
  215. }
  216. // Initialize key manager if it has not been set in the options.
  217. if a.keyManager == nil {
  218. var options kmsapi.Options
  219. if a.config.KMS != nil {
  220. options = *a.config.KMS
  221. }
  222. a.keyManager, err = kms.New(context.Background(), options)
  223. if err != nil {
  224. return err
  225. }
  226. }
  227. // Initialize the X.509 CA Service if it has not been set in the options.
  228. if a.x509CAService == nil {
  229. var options casapi.Options
  230. if a.config.AuthorityConfig.Options != nil {
  231. options = *a.config.AuthorityConfig.Options
  232. }
  233. // Set the issuer password if passed in the flags.
  234. if options.CertificateIssuer != nil && a.issuerPassword != nil {
  235. options.CertificateIssuer.Password = string(a.issuerPassword)
  236. }
  237. // Read intermediate and create X509 signer for default CAS.
  238. if options.Is(casapi.SoftCAS) {
  239. options.CertificateChain, err = pemutil.ReadCertificateBundle(a.config.IntermediateCert)
  240. if err != nil {
  241. return err
  242. }
  243. options.Signer, err = a.keyManager.CreateSigner(&kmsapi.CreateSignerRequest{
  244. SigningKey: a.config.IntermediateKey,
  245. Password: []byte(a.password),
  246. })
  247. if err != nil {
  248. return err
  249. }
  250. }
  251. a.x509CAService, err = cas.New(context.Background(), options)
  252. if err != nil {
  253. return err
  254. }
  255. // Get root certificate from CAS.
  256. if srv, ok := a.x509CAService.(casapi.CertificateAuthorityGetter); ok {
  257. resp, err := srv.GetCertificateAuthority(&casapi.GetCertificateAuthorityRequest{
  258. Name: options.CertificateAuthority,
  259. })
  260. if err != nil {
  261. return err
  262. }
  263. a.rootX509Certs = append(a.rootX509Certs, resp.RootCertificate)
  264. sum := sha256.Sum256(resp.RootCertificate.Raw)
  265. log.Printf("Using root fingerprint '%s'", hex.EncodeToString(sum[:]))
  266. }
  267. }
  268. // Read root certificates and store them in the certificates map.
  269. if len(a.rootX509Certs) == 0 {
  270. a.rootX509Certs = make([]*x509.Certificate, len(a.config.Root))
  271. for i, path := range a.config.Root {
  272. crt, err := pemutil.ReadCertificate(path)
  273. if err != nil {
  274. return err
  275. }
  276. a.rootX509Certs[i] = crt
  277. }
  278. }
  279. for _, crt := range a.rootX509Certs {
  280. sum := sha256.Sum256(crt.Raw)
  281. a.certificates.Store(hex.EncodeToString(sum[:]), crt)
  282. }
  283. a.rootX509CertPool = x509.NewCertPool()
  284. for _, cert := range a.rootX509Certs {
  285. a.rootX509CertPool.AddCert(cert)
  286. }
  287. // Read federated certificates and store them in the certificates map.
  288. if len(a.federatedX509Certs) == 0 {
  289. a.federatedX509Certs = make([]*x509.Certificate, len(a.config.FederatedRoots))
  290. for i, path := range a.config.FederatedRoots {
  291. crt, err := pemutil.ReadCertificate(path)
  292. if err != nil {
  293. return err
  294. }
  295. a.federatedX509Certs[i] = crt
  296. }
  297. }
  298. for _, crt := range a.federatedX509Certs {
  299. sum := sha256.Sum256(crt.Raw)
  300. a.certificates.Store(hex.EncodeToString(sum[:]), crt)
  301. }
  302. // Decrypt and load SSH keys
  303. var tmplVars templates.Step
  304. if a.config.SSH != nil {
  305. if a.config.SSH.HostKey != "" {
  306. signer, err := a.keyManager.CreateSigner(&kmsapi.CreateSignerRequest{
  307. SigningKey: a.config.SSH.HostKey,
  308. Password: []byte(a.sshHostPassword),
  309. })
  310. if err != nil {
  311. return err
  312. }
  313. // If our signer is from sshagentkms, just unwrap it instead of
  314. // wrapping it in another layer, and this prevents crypto from
  315. // erroring out with: ssh: unsupported key type *agent.Key
  316. switch s := signer.(type) {
  317. case *sshagentkms.WrappedSSHSigner:
  318. a.sshCAHostCertSignKey = s.Sshsigner
  319. case crypto.Signer:
  320. a.sshCAHostCertSignKey, err = ssh.NewSignerFromSigner(s)
  321. default:
  322. return errors.Errorf("unsupported signer type %T", signer)
  323. }
  324. if err != nil {
  325. return errors.Wrap(err, "error creating ssh signer")
  326. }
  327. // Append public key to list of host certs
  328. a.sshCAHostCerts = append(a.sshCAHostCerts, a.sshCAHostCertSignKey.PublicKey())
  329. a.sshCAHostFederatedCerts = append(a.sshCAHostFederatedCerts, a.sshCAHostCertSignKey.PublicKey())
  330. }
  331. if a.config.SSH.UserKey != "" {
  332. signer, err := a.keyManager.CreateSigner(&kmsapi.CreateSignerRequest{
  333. SigningKey: a.config.SSH.UserKey,
  334. Password: []byte(a.sshUserPassword),
  335. })
  336. if err != nil {
  337. return err
  338. }
  339. // If our signer is from sshagentkms, just unwrap it instead of
  340. // wrapping it in another layer, and this prevents crypto from
  341. // erroring out with: ssh: unsupported key type *agent.Key
  342. switch s := signer.(type) {
  343. case *sshagentkms.WrappedSSHSigner:
  344. a.sshCAUserCertSignKey = s.Sshsigner
  345. case crypto.Signer:
  346. a.sshCAUserCertSignKey, err = ssh.NewSignerFromSigner(s)
  347. default:
  348. return errors.Errorf("unsupported signer type %T", signer)
  349. }
  350. if err != nil {
  351. return errors.Wrap(err, "error creating ssh signer")
  352. }
  353. // Append public key to list of user certs
  354. a.sshCAUserCerts = append(a.sshCAUserCerts, a.sshCAUserCertSignKey.PublicKey())
  355. a.sshCAUserFederatedCerts = append(a.sshCAUserFederatedCerts, a.sshCAUserCertSignKey.PublicKey())
  356. }
  357. // Append other public keys and add them to the template variables.
  358. for _, key := range a.config.SSH.Keys {
  359. publicKey := key.PublicKey()
  360. switch key.Type {
  361. case provisioner.SSHHostCert:
  362. if key.Federated {
  363. a.sshCAHostFederatedCerts = append(a.sshCAHostFederatedCerts, publicKey)
  364. } else {
  365. a.sshCAHostCerts = append(a.sshCAHostCerts, publicKey)
  366. }
  367. case provisioner.SSHUserCert:
  368. if key.Federated {
  369. a.sshCAUserFederatedCerts = append(a.sshCAUserFederatedCerts, publicKey)
  370. } else {
  371. a.sshCAUserCerts = append(a.sshCAUserCerts, publicKey)
  372. }
  373. default:
  374. return errors.Errorf("unsupported type %s", key.Type)
  375. }
  376. }
  377. }
  378. // Configure template variables. On the template variables HostFederatedKeys
  379. // and UserFederatedKeys we will skip the actual CA that will be available
  380. // in HostKey and UserKey.
  381. //
  382. // We cannot do it in the previous blocks because this configuration can be
  383. // injected using options.
  384. if a.sshCAHostCertSignKey != nil {
  385. tmplVars.SSH.HostKey = a.sshCAHostCertSignKey.PublicKey()
  386. tmplVars.SSH.HostFederatedKeys = append(tmplVars.SSH.HostFederatedKeys, a.sshCAHostFederatedCerts[1:]...)
  387. } else {
  388. tmplVars.SSH.HostFederatedKeys = append(tmplVars.SSH.HostFederatedKeys, a.sshCAHostFederatedCerts...)
  389. }
  390. if a.sshCAUserCertSignKey != nil {
  391. tmplVars.SSH.UserKey = a.sshCAUserCertSignKey.PublicKey()
  392. tmplVars.SSH.UserFederatedKeys = append(tmplVars.SSH.UserFederatedKeys, a.sshCAUserFederatedCerts[1:]...)
  393. } else {
  394. tmplVars.SSH.UserFederatedKeys = append(tmplVars.SSH.UserFederatedKeys, a.sshCAUserFederatedCerts...)
  395. }
  396. // Check if a KMS with decryption capability is required and available
  397. if a.requiresDecrypter() {
  398. if _, ok := a.keyManager.(kmsapi.Decrypter); !ok {
  399. return errors.New("keymanager doesn't provide crypto.Decrypter")
  400. }
  401. }
  402. // TODO: decide if this is a good approach for providing the SCEP functionality
  403. // It currently mirrors the logic for the x509CAService
  404. if a.requiresSCEPService() && a.scepService == nil {
  405. var options scep.Options
  406. // Read intermediate and create X509 signer and decrypter for default CAS.
  407. options.CertificateChain, err = pemutil.ReadCertificateBundle(a.config.IntermediateCert)
  408. if err != nil {
  409. return err
  410. }
  411. options.CertificateChain = append(options.CertificateChain, a.rootX509Certs...)
  412. options.Signer, err = a.keyManager.CreateSigner(&kmsapi.CreateSignerRequest{
  413. SigningKey: a.config.IntermediateKey,
  414. Password: []byte(a.password),
  415. })
  416. if err != nil {
  417. return err
  418. }
  419. if km, ok := a.keyManager.(kmsapi.Decrypter); ok {
  420. options.Decrypter, err = km.CreateDecrypter(&kmsapi.CreateDecrypterRequest{
  421. DecryptionKey: a.config.IntermediateKey,
  422. Password: []byte(a.password),
  423. })
  424. if err != nil {
  425. return err
  426. }
  427. }
  428. a.scepService, err = scep.NewService(context.Background(), options)
  429. if err != nil {
  430. return err
  431. }
  432. // TODO: mimick the x509CAService GetCertificateAuthority here too?
  433. }
  434. if a.config.AuthorityConfig.EnableAdmin {
  435. // Initialize step-ca Admin Database if it's not already initialized using
  436. // WithAdminDB.
  437. if a.adminDB == nil {
  438. if a.linkedCAToken == "" {
  439. // Check if AuthConfig already exists
  440. a.adminDB, err = adminDBNosql.New(a.db.(nosql.DB), admin.DefaultAuthorityID)
  441. if err != nil {
  442. return err
  443. }
  444. } else {
  445. // Use the linkedca client as the admindb.
  446. client, err := newLinkedCAClient(a.linkedCAToken)
  447. if err != nil {
  448. return err
  449. }
  450. // If authorityId is configured make sure it matches the one in the token
  451. if id := a.config.AuthorityConfig.AuthorityID; id != "" && !strings.EqualFold(id, client.authorityID) {
  452. return errors.New("error initializing linkedca: token authority and configured authority do not match")
  453. }
  454. client.Run()
  455. a.adminDB = client
  456. }
  457. }
  458. // Initialize the default cache pool.
  459. if a.cachePool == nil {
  460. a.cachePool = cache.DefaultPool()
  461. }
  462. provs, err := a.adminDB.GetProvisioners(context.Background())
  463. if err != nil {
  464. return admin.WrapErrorISE(err, "error loading provisioners to initialize authority")
  465. }
  466. if len(provs) == 0 && !strings.EqualFold(a.config.AuthorityConfig.DeploymentType, "linked") {
  467. // Create First Provisioner
  468. prov, err := CreateFirstProvisioner(context.Background(), a.adminDB, string(a.password))
  469. if err != nil {
  470. return admin.WrapErrorISE(err, "error creating first provisioner")
  471. }
  472. // Create first admin
  473. if err := a.adminDB.CreateAdmin(context.Background(), &linkedca.Admin{
  474. ProvisionerId: prov.Id,
  475. Subject: "step",
  476. Type: linkedca.Admin_SUPER_ADMIN,
  477. }); err != nil {
  478. return admin.WrapErrorISE(err, "error creating first admin")
  479. }
  480. }
  481. }
  482. // Load Provisioners and Admins
  483. if err := a.reloadAdminResources(context.Background()); err != nil {
  484. return err
  485. }
  486. // Configure templates, currently only ssh templates are supported.
  487. if a.sshCAHostCertSignKey != nil || a.sshCAUserCertSignKey != nil {
  488. a.templates = a.config.Templates
  489. if a.templates == nil {
  490. a.templates = templates.DefaultTemplates()
  491. }
  492. if a.templates.Data == nil {
  493. a.templates.Data = make(map[string]interface{})
  494. }
  495. a.templates.Data["Step"] = tmplVars
  496. }
  497. // JWT numeric dates are seconds.
  498. a.startTime = time.Now().Truncate(time.Second)
  499. // Set flag indicating that initialization has been completed, and should
  500. // not be repeated.
  501. a.initOnce = true
  502. return nil
  503. }
  504. // GetDatabase returns the authority database. If the configuration does not
  505. // define a database, GetDatabase will return a db.SimpleDB instance.
  506. func (a *Authority) GetDatabase() db.AuthDB {
  507. return a.db
  508. }
  509. // GetAdminDatabase returns the admin database, if one exists.
  510. func (a *Authority) GetAdminDatabase() admin.DB {
  511. return a.adminDB
  512. }
  513. // IsAdminAPIEnabled returns a boolean indicating whether the Admin API has
  514. // been enabled.
  515. func (a *Authority) IsAdminAPIEnabled() bool {
  516. return a.config.AuthorityConfig.EnableAdmin
  517. }
  518. // Shutdown safely shuts down any clients, databases, etc. held by the Authority.
  519. func (a *Authority) Shutdown() error {
  520. if err := a.keyManager.Close(); err != nil {
  521. log.Printf("error closing the key manager: %v", err)
  522. }
  523. return a.db.Shutdown()
  524. }
  525. // CloseForReload closes internal services, to allow a safe reload.
  526. func (a *Authority) CloseForReload() {
  527. if err := a.keyManager.Close(); err != nil {
  528. log.Printf("error closing the key manager: %v", err)
  529. }
  530. if client, ok := a.adminDB.(*linkedCaClient); ok {
  531. client.Stop()
  532. }
  533. }
  534. // IsRevoked returns whether or not a certificate has been
  535. // revoked before.
  536. func (a *Authority) IsRevoked(sn string) (bool, error) {
  537. // Check the passive revocation table.
  538. if lca, ok := a.adminDB.(interface {
  539. IsRevoked(string) (bool, error)
  540. }); ok {
  541. return lca.IsRevoked(sn)
  542. }
  543. return a.db.IsRevoked(sn)
  544. }
  545. // requiresDecrypter returns whether the Authority
  546. // requires a KMS that provides a crypto.Decrypter
  547. // Currently this is only required when SCEP is
  548. // enabled.
  549. func (a *Authority) requiresDecrypter() bool {
  550. return a.requiresSCEPService()
  551. }
  552. // requiresSCEPService iterates over the configured provisioners
  553. // and determines if one of them is a SCEP provisioner.
  554. func (a *Authority) requiresSCEPService() bool {
  555. for _, p := range a.config.AuthorityConfig.Provisioners {
  556. if p.GetType() == provisioner.TypeSCEP {
  557. return true
  558. }
  559. }
  560. return false
  561. }
  562. // GetSCEPService returns the configured SCEP Service
  563. // TODO: this function is intended to exist temporarily
  564. // in order to make SCEP work more easily. It can be
  565. // made more correct by using the right interfaces/abstractions
  566. // after it works as expected.
  567. func (a *Authority) GetSCEPService() *scep.Service {
  568. return a.scepService
  569. }