[Swan] RSA keys help

Kostya Vasilyev kman at fastmail.com
Wed Jan 23 15:13:45 UTC 2019

Hmm... Something interesting.

ipsec-tools has a utility called plainrsa-gen which can generate RFC 3110 format keys.

Output looks like this (this is a 512 bit key for brevity):

# : PUB 0sAQPBu6FSgczYJ5jjqE4rQj1m2PIC2oiHL4h6VhicQRP3xQ==
: RSA	{
	# RSA 256 bits
	# pubkey=0sAQPBu6FSgczYJ5jjqE4rQj1m2PIC2oiHL4h6VhicQRP3xQ==
	Modulus: 0xc1bba15281ccd82798e3a84e2b423d66d8f202da88872f887a56189c4113f7c5
	PublicExponent: 0x03
	PrivateExponent: 0x8127c0e1abdde56fbb4270341cd6d398bd0376dfa632f2f89b0118b27d89edeb
	Prime1: 0xe1006e0fedd5b3ceeb23d3af2552cd5d
	Prime2: 0xdc6c627b21650f44a6b09fe15f724589
	Exponent1: 0x9600495ff3e3cd349cc28d1f6e373393
	Exponent2: 0x92f2ec5216435f8319cb1540ea4c2e5b
	Coefficient: 0xcbfd904423e9e83f8363823d512e9b87

On my Fedora home system, it can also import from openssl private / public format key files (not on Debian where I have LibreSwan but that doesn't matter I can do the conversion on Fedora).

And unless this documentation is outdated, I should be able to put the server's private key into ipsec.secrets (not NSS) even with LibreSwan:


The public keys (both the server's and the client's) can go into {left,right}rsasigkey in ipsec.conf as described here:


and here:


I'll be trying this now, will report back.

Kostya Vasilyev
kman at fastmail.com

On Wed, Jan 23, 2019, at 5:50 PM, Kostya Vasilyev wrote:
> Re: keys only auth
> I'm following this guide:
> https://libreswan.org/wiki/Host_to_host_VPN
> Which is under:
> https://libreswan.org/wiki/Configuration_examples
> As you can see it uses NSS for key generation and storage.
> I actually got rsa key auth to work with StrongSwan but it seems less 
> stable than Libre (was dropping connections and slow to re-establish).
> Yes I know the syntax for adding alt subject names, thanks. The problem 
> is Mikrotik wants something specific there (from server cert) and I 
> can't figure out what, it seems undocumented. Some people say it wants 
> an email address (any email address) but that didn't work.
> Anyway to keep from straying too far...
> ...has anyone used rsa key *only* auth with Libre where the other side 
> was a different system (not Libre)? How did you manage your keys?
> Any suggestions on keys management?
> -- 
> Kostya Vasilyev
> kman at fastmail.com
> On Wed, Jan 23, 2019, at 5:41 PM, Derek Cameron wrote:
> > Yes, my use case included both the certificate and the private key for
> > the client. I have never heard of authentication with only a key and
> > no certificate, except in the case of a preshared key (PSK). I added
> > the subjectAltName to the client certificate with the -8 switch. e.g.
> > 
> > certutil -S -c "ExampleCA" -n "client1.example.com" -s
> > "O=Example,CN=client1.example.com" -k rsa -v 12 -d sql:test -t ",," -1
> > -6 -8 "client1.example.com"
> > 
> > On Wed, Jan 23, 2019 at 6:27 AM Kostya Vasilyev <kman at fastmail.com> wrote:
> > >
> > > Were you exporting keys that are part of some certificates?
> _______________________________________________
> Swan mailing list
> Swan at lists.libreswan.org
> https://lists.libreswan.org/mailman/listinfo/swan

More information about the Swan mailing list