Php api平台:LexikJWTAuthenticationBundle无法加载私钥

Php api平台:LexikJWTAuthenticationBundle无法加载私钥,php,api,symfony,bundle,api-platform.com,Php,Api,Symfony,Bundle,Api Platform.com,我正在使用api paltform创建一个身份验证api,这是下面的教程。 我有个问题: 无法加载私钥 “C:\wamp64\www\auth-api\app/。/var/jwt/private.pem”:0906A068:pem 例程:PEM_do_头:错误的密码读取 security.yml security: encoders: FOS\UserBundle\Model\UserInterface: bcrypt providers: fos_userbundle:

我正在使用api paltform创建一个身份验证api,这是下面的教程。

我有个问题:

无法加载私钥 “C:\wamp64\www\auth-api\app/。/var/jwt/private.pem”:0906A068:pem 例程:PEM_do_头:错误的密码读取

security.yml

security:
encoders:
    FOS\UserBundle\Model\UserInterface: bcrypt


providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    login:
        pattern:  ^/login
        stateless: true
        anonymous: true
        provider: fos_userbundle
        form_login:
            check_path: /login_check
            username_parameter: _username
            password_parameter: _password
            success_handler: lexik_jwt_authentication.handler.authentication_success
            failure_handler: lexik_jwt_authentication.handler.authentication_failure
            require_previous_session: false

    main:
        pattern:   ^/
        provider: fos_userbundle
        stateless: true
        anonymous: true
        lexik_jwt: ~

    dev:
        pattern:  ^/(_(profiler|wdt)|css|images|js)/
        security: false

access_control:
    - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, roles: IS_AUTHENTICATED_FULLY }
config.yml

imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }

# Put parameters here that don't need to change on each machine where the 
app  is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
     locale: en

framework:
    #esi:             ~
    #translator:      { fallbacks: ["%locale%"] }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    serializer:      { enable_annotations: true }
    templating:
        engines: ['twig']
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
         # http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
        handler_id:  session.handler.native_file
        save_path:   "%kernel.root_dir%/../var/sessions/%kernel.environment%"
    fragments:       ~
    http_method_override: true
    assets: ~
    php_errors:
        log: true

# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
    # if using pdo_sqlite as your database driver:
    #   1. add the path in parameters.yml
    #     e.g. database_path: "%kernel.root_dir%/data/data.db3"
    #   2. Uncomment database_path in parameters.yml.dist
    #   3. Uncomment next line:
    #     path:     "%database_path%"

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }

# Nelmio CORS
nelmio_cors:
    defaults:
        allow_origin:   ["%cors_allow_origin%"]
        allow_methods:  ["POST", "PUT", "GET", "DELETE", "OPTIONS"]
        allow_headers:  ["content-type", "authorization"]
        expose_headers: ["link"]
        max_age:        3600
    paths:
        '^/': ~

fos_user:
    db_driver: orm # other valid values are 'mongodb' and 'couchdb'
    firewall_name: main
    user_class: AppBundle\Entity\User
    from_email:
        address: noreplay@noreplay.com
        sender_name: noreplay

lexik_jwt_authentication:
    private_key_path: '%jwt_private_key_path%'
    public_key_path:  '%jwt_public_key_path%'
    pass_phrase:      '%jwt_key_pass_phrase%'
    token_ttl:        '%jwt_token_ttl%'
路由.yml

api:
    resource: '.'
    type:     'api_platform'

app:
    resource: '@AppBundle/Action/'
    type:     'annotation'

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

login_check:
    path: /login_check

安装LexikJWTAuthenticatioBundle时,需要从控制台启动此命令

$ openssl genrsa -out var/jwt/private.pem -aes256 4096
$ openssl rsa -pubout -in var/jwt/private.pem -out var/jwt/public.pem
您需要插入密码并将其添加到您的
参数中。yml
关联到变量:
jwt\u key\u pass\u phrase

像这样:

jwt_key_pass_phrase: ''

您应该直接查看的文档,因为它并没有真正链接到api平台


这可能意味着私钥是错误的。

您是否插入了内部参数。yml字段jwt\u key\u pass\u短语是否正确?@AlessandroMinoccheri是的,我有它,他没有一个值jwt\u key\u pass\u短语:''当您启动时,例如:openssl genrsa-out var/jwt/private.pem-AES2564096,您是否将值保留为空完成参数。yml?非常感谢@AlessandroMinoccheri这就是问题所在。我会给出答案,这样你就可以接受了