VPN cannot connect after MacOS system is updated

After the MacOS version is updated to 12.6.1, the personal VPN cannot be connected. After troubleshooting, the sharedSecretReference may be invalid.(The sharedSecretReference is obtained from the keychain)

os update before: security default-kechain-> "/Users/admin/Library/Keychains/login.keychain-db"

os update after: security default-kechain-> security: SecKeychainCopyDefault: A default keychain could not be found.

Although it can be corrected by this command :security default-keychain -s "/Library/Keychains/System.keychain" then,VPN can connect.

I wonder if it is possible to fix this problem through code? Or is the code OK? This is a bug in the Apple system?