Re: [strongSwan] How to use Strongswan 5.0.1 Smartcard correctly?

2012-10-12 Thread Martin Willi
Hi,

  Does your token contain a public key object that is readable without login?
 
 [[GR]] Yes

 pkcs11-tool --module /usr/lib/libetpkcs11.so -O -l --private
 Please enter User PIN: 
 Private Key Object; RSA 
   label:  eTCAPI private key
   ID: 
 39453945373335312d333545442d343031612d384637302d3238463636393036363042303a30
   Usage:  decrypt, sign, unwrap
 Private Key Object; RSA 
   label:  eTCAPI private key
   ID: 
 39453945373335312d333545442d343031612d384637302d3238463636393036363042303a31
   Usage:  decrypt, sign, unwrap
 Certificate Object, type = X.509 cert
   label:  (eTCAPI) richter3's  ID
   ID: 
 39453945373335312d333545442d343031612d384637302d3238463636393036363042303a30
 Certificate Object, type = X.509 cert
   label:  (eTCAPI) richter3's  ID
   ID: 
 39453945373335312d333545442d343031612d384637302d3238463636393036363042303a31

I don't see a public key object at all, even with login. If you generate
a keypair using PKCS#11, this usually results in both a public and a
private key.

If your private key does not have an associated public key, our pkcs11
backend can't use it (because it can't fingerprint the key). As a
work-around, you can try to extract the certificate, the public key in
it, and store the plain public key with the correct ID back to the
token.

I don't know how exotic it is that a public key is missing, I've never
seen such a token. But if it is not that uncommon, we might provide a
fallback that reads the public key from the certificate.

 : PIN %smartcard1@etoken-module %prompt

 charon: 15[CFG] line 22: the given %smartcard specifier is invalid

You still have to provide the keyid select the private key. But if you
define slot, module and keyid, pkcs11 does not have to search for a
public key without login, but can immediately login to the token and
load the private key. Anyway, it doesn't help in your case, as the
public key is completely missing.

 Is there another way to specify the private key in addition to give the
 subject as leftid?

No. The certificate is selected based on the leftid. Once we have a
certificate, we look for a private key with a matching keyid (not the
CKA_ID, but the computed hash over the public key).

Regards
Martin


___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users


Re: [strongSwan] How to use Strongswan 5.0.1 Smartcard correctly?

2012-10-12 Thread richter
Hi Martin,

 
 I don't see a public key object at all, even with login. If you generate a 
 keypair
 using PKCS#11, this usually results in both a public and a private key.
 
 If your private key does not have an associated public key, our pkcs11
 backend can't use it (because it can't fingerprint the key). As a work-around,
 you can try to extract the certificate, the public key in it, and store the 
 plain
 public key with the correct ID back to the token.
 
 I don't know how exotic it is that a public key is missing, I've never seen 
 such
 a token. But if it is not that uncommon, we might provide a fallback that
 reads the public key from the certificate.
 

[[GR]] That's an eToken and the Certificate was written with Safenet Windows 
Software (using Window CAPI). I also tested with a newer eToken with a Javacard 
instead of Siemens OS, but same behavior.

You can't tell me that (Aladdin/Safenet) eTokens are exotic...

What might make the difference is, that the certificates are written with 
Windows CAPI and not using pkcs#11, but this is also not very exotic.

The same Token with the same certificates worked for years with pluto and are 
still working with openvpn on linux, without the need to extract the 
certificate. Pluto does not search for a public key, but for a certificate. I 
didn't looked deeper into it, but I guess it always takes the public key from 
the certificate instead of searching for a public key (because it nowhere in 
the source searches for a public key). 

So it seems that what you describe as fallback above, was the default in pluto?

If you give me a few hints where to start I might be able to provide a patch.

 
  Is there another way to specify the private key in addition to give
  the subject as leftid?
 
 No. The certificate is selected based on the leftid. Once we have a 
 certificate,
 we look for a private key with a matching keyid (not the CKA_ID, but the
 computed hash over the public key).
 

[[GR]] The problem on the second token, which has a public key (that is listed 
with pcks11-tool) and where the private key is loaded correctly: I have two 
certificates with the same subject (different usage (sign, encrypt). So is 
there a way to tell strongswan which certificate to use (I can't change the 
smartcard)?

And why is the private key found during ipsec secrets, but not when I start 
the connection:

Both keys get loaded:
Oct 12 08:35:01 ThinClient charon: 04[CFG]   loaded private key from 
%smartcard:70ee03ef 
Oct 12 08:35:01 ThinClient charon: 04[CFG]   loaded private key from 
%smartcard:70ee03f0

But when I start the connection:
Oct 12 08:36:04 ThinClient charon: 13[IKE] no RSA private key found for 'C=DE, 
SN=018388793001, CN=Gerald Richter, S=Richter, G=Gerald, 
E=g...@.de, 2b:06:01:05:05:07:09:03=M'

Thanks  Regards

Gerald




___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users


Re: [strongSwan] How to use Strongswan 5.0.1 Smartcard correctly?

2012-10-12 Thread Martin Willi

 You can't tell me that (Aladdin/Safenet) eTokens are exotic...

It's not about the token itself, but how the keys and certificates are
deployed on it.

 What might make the difference is, that the certificates are written
 with Windows CAPI and not using pkcs#11, but this is also not very
 exotic.

That's probably the problem. If you generate keys with PKCS#11 on the
token, you always get a keypair. This might be different with CAPI, or
at least with your software.

 If you give me a few hints where to start I might be able to provide a
 patch.

I'll have a look at it next week, shouldn't be too hard to implement
this fallback.

 I have two certificates with the same subject (different usage (sign,
 encrypt). So is there a way to tell strongswan which certificate to use
 (I can't change the smartcard)?

No, currently not. 

 And why is the private key found during ipsec secrets, but not when I
 start the connection:

The loaded private key is later looked up using the computed
fingerprint. Either the pkcs11 backend can't fingerprint the associated
public key, or the fingerprints don't match.

Regards
Martin


___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users


Re: [strongSwan] How to use Strongswan 5.0.1 Smartcard correctly?

2012-10-12 Thread richter
Hi,

 
  You can't tell me that (Aladdin/Safenet) eTokens are exotic...
 
 It's not about the token itself, but how the keys and certificates are 
 deployed
 on it.


Yes, of course it's not the token, but the windows software that comes with 
Aladdin/Safenet Tokens is the standard software that everybody uses who uses 
eToken on Windows and I think eToken are widely used.

 
 I'll have a look at it next week, shouldn't be too hard to implement this
 fallback.
 

[[GR]] Thanks!

  I have two certificates with the same subject (different usage (sign,
  encrypt). So is there a way to tell strongswan which certificate to
  use (I can't change the smartcard)?
 
 No, currently not.

[[GR]] Ok, can you tell me where in the source the certificate selection takes 
place?

 
  And why is the private key found during ipsec secrets, but not when
  I start the connection:
 
 The loaded private key is later looked up using the computed fingerprint.
 Either the pkcs11 backend can't fingerprint the associated public key, or the
 fingerprints don't match.
 

[[GR]] The computed fingerprint of what? 
Do I understand right:

1 the certificate is selected using the first certificate that has a matching 
subject  compared to leftid
2 the fingerprint of the associated public key is computed
3 from any private key, you compute the public key and compute the fingerprint 
of that public key
4 These fingerprints from 3 are compared the fingerprint from 2 and the 
matching one is selected

In this case we have a pkcs11 from our customer, so that might have a problem, 
so I like to understand how strongswan is selecting the key, so I can figure 
out if it is a pkcs11 or strongswan problem.

Thanks  Regards

Gerald



 Regards
 Martin



___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users


Re: [strongSwan] How to use Strongswan 5.0.1 Smartcard correctly?

2012-10-12 Thread Martin Willi

 [[GR]] Ok, can you tell me where in the source the certificate
 selection takes place?

IKE asks for a private key for a given identity. The credential manager
looks for certificates for this identity, and an associated private key.
See [1].

 [[GR]] The computed fingerprint of what? 

SHA1 over the subjectPublicKey ASN.1 encoding (KEYID_PUBKEY_SHA1).

 1 the certificate is selected using the first certificate that has a matching 
 subject  compared to leftid
 2 the fingerprint of the associated public key is computed
 3 from any private key, you compute the public key and compute the 
 fingerprint of that public key
 4 These fingerprints from 3 are compared the fingerprint from 2 and the 
 matching one is selected

Yes, that's correct.

Regards
Martin

[1]http://git.strongswan.org/?p=strongswan.git;a=blob;f=src/libstrongswan/credentials/credential_manager.c;hb=HEAD#l1044



___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users


[strongSwan] Procedure generate Authentication-Failed notification for IKEV1 tunnel establishment

2012-10-12 Thread vinay.prabhakar
Hi,

For testing purpose I want to generate IKEV1 tunnel establishment failure 
scenario with notification AUTHENTICATION-FAILED.

On below site I found some ways to generate this scenario but I am getting 
INVALID-ID-INFORMATION notification instead of AUTHENTICATION-FAILED 
notification.

https://lists.strongswan.org/pipermail/users/2008-November/002900.html


We are using 4.5.0 on one side and other side uses 4.6.2 strongswan versions.

In case of IKEV2 if I have a totally different set of certificates (CA key, 
public key  private pair) on both the nodes I can see AUTHENTICATION-FAILED 
notification during tunnel establishment. Why not the same is observed with 
IKEV1 as well?



Kindly let me know how to generate notification AUTHENTICATION-FAILED.ks

Thanks,
Vinay

Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email. 

www.wipro.com
___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users

[strongSwan] Procedure generate Authentication-Failed notification for IKEV1 tunnel establishment

2012-10-12 Thread shubhada.pukale
Hi,

For testing purpose I want to generate IKEV1 tunnel establishment failure 
scenario with notification AUTHENTICATION-FAILED.

On below site I found some ways to generate this scenario but I am getting 
INVALID-ID-INFORMATION notification instead of AUTHENTICATION-FAILED 
notification.

https://lists.strongswan.org/pipermail/users/2008-November/002900.html


We are using 4.5.0 on one side and other side uses 4.6.2 strongswan versions.

In case of IKEV2 if I have a totally different set of certificates (CA key, 
public key  private pair) on both the nodes I can see AUTHENTICATION-FAILED 
notification during tunnel establishment. Why not the same is observed with 
IKEV1 as well?



Kindly let me know how to generate notification AUTHENTICATION-FAILED.


Regards,
Shubhada

Please do not print this email unless it is absolutely necessary. 

The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email. 

www.wipro.com
___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users

Re: [strongSwan] How to use Strongswan 5.0.1 Smartcard correctly?

2012-10-12 Thread Tobias Brunner
Hi Gerald,

 Do I understand right:
 
 1 the certificate is selected using the first certificate that has a matching 
 subject  compared to leftid
 2 the fingerprint of the associated public key is computed
 3 from any private key, you compute the public key and compute the 
 fingerprint of that public key
 4 These fingerprints from 3 are compared the fingerprint from 2 and the 
 matching one is selected

Actually, step 3 does not happen exactly like this.  When the private
key is loaded (not actually the key of course as that is safely stored
on the token) a public key with the same CKA_ID is searched, if none is
found the private key will be destroyed, hence you should see that in
the log when the secrets are loaded.  There is actually a TODO in the
code in regards to extracting the public key from a certificate if no
public key is found [1].

Also, I think it wouldn't be that hard to introduce the ability to load
a specific certificate via left|rightcert (and cacert in ca sections)
similar to pluto (but with the same syntax used now in ipsec.secrets)
plus an option to disable the automatic loading of certificates (which
could be problematic anyway, e.g. if lots of certificates are stored on
the token and, thus, starting charon will take a long time, in which
case starter might kill it).

Regards,
Tobias

[1]
http://git.strongswan.org/?p=strongswan.git;a=blob;f=src/libstrongswan/plugins/pkcs11/pkcs11_public_key.c#l889


___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users


[strongSwan] understanding libhydra kernel interface

2012-10-12 Thread Ravi Kanth Vanapalli
Hi all,

I am having trouble interpreting the plugins of libhydra, specifically
understanding the interfaces which communicate with kernel.

Scenario:* using SS client for IKEv2.*

Web link below indicates that  by default 'kernel-netlink' of libhydra will
be loaded by default for communicating with kernel net-key ipsec stack.

http://wiki.strongswan.org/projects/strongswan/wiki/Pluginlist

which means.. as per my understanding of code base.

Following would be the flow ,
*i)* ipsec start  -- starts the starter in starter.c
   There is a call  libhydra_init(starter) -- initalize kernel
interfaces specific to 'starter' for the kernel.
*iii) *Starter starts the  Charon daemon  in line 714 of starter.c.
*iii)* Inside charon.c line
   *a)* again  libhydra_init(charon)  line 472 -- initialize the
kernel interfaces ( including netlink interface) specific to the 'charon'
for the kernel
 *  b)*  line 572 Initalize the charon daemon with 'charon.load' which
reads libhydra plugins from strongswan.conf pertaning to charon.

In Step* b*) above, there is a plugin called 'kernel-netlink' which
initializes the netlink kernel interfaces for NETKEY ipsec and netlink
kernel interfaces for network. ( line 46,48 of kernel_netlink_plugin.c )

   My question is, why should we initialize the kernel interface eg.
'kernel-netlink' again when step a) already initializes the
'kernel-netlink'  interfaces in libhydra_init.

   Why should the Charon daemon specifically initalize its kernel
interfaces like in step b, when libhydra daemon for Charon..already does it
in step a.

I am not sure if my understanding or reasoning is correct and I would
deeply apppreciate any help to clarify my doubt.

Regards,
RV
___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users

[strongSwan] GSM modem running strongSwan problems

2012-10-12 Thread Jacob Abel
Hello all,

 

I have a Phoenix Contact GSM modem that I've been trying to configure as a
VPN server. The device is a Linux box running strongSwan, and because of the
web interface I have very limited control over the configuration. I've been
trying to connect to it without luck. It gets through the Phase 1
authentication and then fails at Phase 2. The problem seems to be a NAT
problem (where I don't know), as here is the relevant error from the log
(IPs replaced):

 

Oct 11 11:30:12 pluto[1405]: vpn1[2] [office_ip]:4500 #1: cannot respond
to IPsec SA request because no connection is known for
192.168.9.0/24===[modem_ip]:4500...[office_ip]:4500[192.168.0.15]===192.168.
0.240/32

 

Here's what I can tell you:

 

PSK for auth, not using certs

 

On the GSM modem:
Internal IP address: 192.168.0.1
External IP address: [modem_ip]
(on the VPN settings page):
Address Remote Network: 192.168.9.0/24
Address Local Network: 192.168.0.0/24
Local 1:1 NAT is unchecked

 

Office's setup:
Our router address: 192.168.0.1
External IP address: [office_ip]
My computer's IP address: 192.168.0.15

 

VPN client setup (GreenBow, tried Windows' built-in functionality first):
VPN client address: 192.168.0.240
Address type: subnet address
Remote LAN address: 192.168.9.0
Subnet mask: 255.255.255.0

 

The GreenBow client told me Wrong Remote Address, and when I try to
connect with Windows it tells me Error 789: The L2TP connection attempt
failed because the security layer encountered a processing error during
initial negotiations with the remote computer. and the modem's log shows:

 

Feb 20 13:08:43 pluto[1162]: vpn1[2] [office_ip]:58385 #1: cannot respond
to IPsec SA request because no connection is known for
[modem_ip]:4500:17/1701...[office_ip]:58385[192.168.0.15]:17/1701===192.168.
0.15/32

 

In Windows, I have the VPN connection's security set to L2TP/IPSec with the
PSK in place in the advanced settings, everything else left as default.

 

Any help would be greatly appreciated. I've tried so many different
combinations in all the fields with IP addresses without any luck. Is this a
problem with my office's router, the GSM router, or what? It's got to be
some sort of NAT problem.

 

Regards,

 

Jacob Abel
Project Engineer
Accuflow, Inc.
4801 District Blvd.
Bakersfield, CA 93313
 http://www.accuflow.com/ www.accuflow.com

 

___
Users mailing list
Users@lists.strongswan.org
https://lists.strongswan.org/mailman/listinfo/users