Configure openvpn client gives "SubjectKeyIdentifier extension" error.

mazdlc

Cadet
Joined
Feb 9, 2022
Messages
1
Recently I install Softether VPN Server on my asus router, it accepts both l2tp and openvpn clients. I had success with l2tp clients, but appears that I have to set up openvpn client on truenas scale.
Following TrueNAS and OpenVPN client configuration , I imported CA and certificate from the .ovpn file provided by Softether VPN Server, but cannot use them in openvpn client configuration. It gives "must have SubjectKeyIdentifier extension set" errors.
error.PNG


I wonder if that is a problem with the softether server config or my client/certificate config, how could I solve it
 

ThreepE0

Cadet
Joined
Jun 28, 2022
Messages
4
Found a fix after way too many hours of digging around online, and much frustration. You're using the local Truenas certs in your example, so that'll never work.

What is typically required is to enter CA (from the VPN provider or your local VPN server) that signed the client cert (again from the VPN provider or your local VPN server) that is going to be trusted by your VPN provider (or local VPN server.) Both of these need to be installed ahead of configuring either the client/server section. With OpenVPN Cloud for example, the easiest way is to download a config from their portal, take the certs from their config, and import. There are a few examples of how to do this around the web so I won't belabor the point too much.

On to the actual bug: Keep me honest here, but the subjectkeyidentifier should be checked on the CA, and doesn't apply to client certificates. It shouldn't need to be checked on the client certs. So after trying too many other things than I'm happy to admit, I figured I'd check how to disable the check on the client cert, and that's what ended up working for me.

Disclaimer: This is my best effort to provide the best solution I can come up with. I've done my best to do things properly in order to help folks out with the issue. I am not responsible for any breakage or reduction in functionality you may experience while implementing this fix. As always, if you aren't comfortable or sure in what you're doing, do not proceed blindly or without backups and a rollback plan.

"
Code:
#sudo in order to have permission to edit the file.  you'll be prompted for password#
sudo -s
#copy the vpn.py file to root in order to have a backup#
cp /usr/lib/python3/dist-packages/middlewared/plugins/vpn.py /vpn_backup.py
#edit the vpn.py file.  look for the second instance of 'subjectkeyidentifier' and remove it#
#be careful to remove the surrounding quotes and comma so the remaining list makes sense#
nano vpn.py
#restart the web interface in order to re-load the resulting vpn.py file#
systemctl restart middlewared

/usr/lib/python3/dist-packages/middlewared/plugins/vpn.py"

Once the web interface comes back up, you should find that you can submit the client config and start the service.
 

Alphonse

Cadet
Joined
Sep 11, 2022
Messages
9
So two notes, this did not solve my problem, it didn't get rid of the error, after removing both of them it did still have the error "client certificate chain could not be verified with specified root CA.", which is still an underlying error.

Also for those trying to use grep to find where in the file they are use 'SubjectKeyIdentifier', as it won't find it in all lower case.

So I wouldn't recomend this fix as its playing with underlying libraries, and have not had my problems fixed with the change.
 

ThreepE0

Cadet
Joined
Jun 28, 2022
Messages
4
So two notes, this did not solve my problem, it didn't get rid of the error, after removing both of them it did still have the error "client certificate chain could not be verified with specified root CA.", which is still an underlying error.

Also for those trying to use grep to find where in the file they are use 'SubjectKeyIdentifier', as it won't find it in all lower case.

So I wouldn't recomend this fix as its playing with underlying libraries, and have not had my problems fixed with the change.
This definitely fixes the issue. I’ve had to use this fix on three NAS units now, using Scale and otherwise. The error message you’re mentioning here is due to the client and ca certs in your config not being matched up. You’ve got to download your ovpn profile, grab the private cert from in there and upload to the NAS. Use that as your private cert. Then grab the ca cert and use that as the ca cert in the NAS. If they don’t match, you’ll get the error message you’ve mentioned here.

As a caution when editing the config file (not a library,) back that file up in another directory first. The service looks in the directory where that file is located and if you have two conflicting files in that directory, the boot process hangs.
 

ThreepE0

Cadet
Joined
Jun 28, 2022
Messages
4
So two notes, this did not solve my problem, it didn't get rid of the error, after removing both of them it did still have the error "client certificate chain could not be verified with specified root CA.", which is still an underlying error.

Also for those trying to use grep to find where in the file they are use 'SubjectKeyIdentifier', as it won't find it in all lower case.

So I wouldn't recomend this fix as its playing with underlying libraries, and have not had my problems fixed with the change.
It’s not “playing around with libraries,” itself addressing the problem with the way the Trunenas config (not library) is shipped out of the box. Until they fix their config, this is the solution. If you need help with your configuration or troubleshooting I’d be happy to help
 
Joined
Dec 11, 2022
Messages
1
Isso definitivamente corrige o problema. Eu tive que usar essa correção em três unidades NAS agora, usando Scale e outros. A mensagem de erro que você está mencionando aqui é porque o cliente e os certs ca em sua configuração não são correspondentes. Você precisa baixar seu perfil ovpn, pegar o certificado privado de lá e fazer o upload para o NAS. Use isso como seu certificado privado. Em seguida, pegue o certificado e use-o como o certificado no NAS. Se eles não corresponderem, você receberá a mensagem de erro mencionada aqui.

Como um cuidado ao editar o arquivo de configuração (não uma biblioteca), faça backup desse arquivo em outro diretório primeiro. O serviço procura no diretório onde esse arquivo está localizado e se você tiver dois arquivos conflitantes nesse diretório, o processo de inicialização trava.
Encontrei uma solução depois de muitas horas de pesquisa on-line e muita coisa escondida. Você está usando os certificados Truenas locais em seu exemplo, então isso nunca funcionará.

O que normalmente é necessário é inserir o CA (do provedor VPN ou do servidor VPN local) que assina o certificado do cliente (novamente do provedor VPN ou do servidor VPN local) que será confiável para o provedor VPN (ou VPN local server.) Ambos precisam ser instalados antes da configuração da seção cliente/servidor. Com o OpenVPN Cloud, por exemplo, a maneira mais fácil é baixar uma configuração de seu portal, obter os certificados de sua configuração e importar. Existem alguns exemplos de como fazer isso na web, então não vou insistir muito no assunto.

Vamos ao bug real: mantenha-me honesto aqui, mas o identificador de subjectkey deve ser verificado na CA e não se aplica a certificados de cliente. Não deve ser verificado nos certificados do cliente. Então, depois de tentar muitas outras coisas do que estou feliz em admitir, pensei em verificar como desabilitar a verificação no certificado do cliente, e foi isso que acabou funcionando para mim.

Isenção de responsabilidade: este é o meu melhor esforço para fornecer a melhor solução possível. Eu fiz o meu melhor para fazer as coisas corretamente para ajudar as pessoas com o problema. Não sou responsável por qualquer quebra ou redução na funcionalidade que você possa ter ao implementar esta correção. Como sempre, se você não estiver confortável ou seguro do que está fazendo, não prossiga cegamente ou sem backups e um plano de reversão.

"
[CÓDIGO]
#sudo para ter permissão para editar o arquivo. você será solicitado a fornecer a senha#
sudo -s
#copie o arquivo vpn.py para root para ter um backup#
cp /usr/lib/python3/dist-packages/middlewared/plugins/vpn.py /vpn_backup.py
#edite o arquivo vpn.py. obtenha uma segunda instância de 'subjectkeyidentifier' e remova-a#
#tenha cuidado para remover aspas e vírgulas ao redor para que a lista restante faça sentido#
nano vpn.py
# reinicie a interface da web para recarregar o arquivo vpn.py resultante#
systemctl reiniciar middleware[/CODE]
/usr/lib/python3/dist-packages/middlewared/plugins/vpn.py"

Depois que a interface da Web voltar, você descobrirá que pode enviar a configuração do cliente e iniciar o serviço.
ola amigo... estou com o mesmo problema,
1) mas se eu mandar conectar direto com o comando openvpn meuperfil.ovpn, ele conecta normal, mas se for importar o certificado da esse problema.
2) Fiz a importação do meu certificado, porem mas não consigo entender onde que tem que removedor
'subjectkeyidentifier' seria só a palavra do arquivo uma linha inteira?
 

Attachments

  • tela-01.png
    tela-01.png
    196.2 KB · Views: 200
  • tela-02.png
    tela-02.png
    205.1 KB · Views: 201
Top